Lee*_*Way 9 coded-ui-tests specflow
我无法为我的功能文件定义[BeforeFeature]/ [AfterFeature]hook.正在测试的应用程序是WPF独立桌面应用程序.
如果我使用[BeforeScenario]/ [AfterScenario]一切正常,应用程序启动没有任何问题,设计的步骤正确执行,应用程序关闭.
一旦我使用与[BeforeFeature]/ [AfterFeature]tags 相同的步骤,应用程序启动并且测试失败,并且:
启动此进程时发生以下错误:对象引用未设置为对象的实例.
这是一个例子:
[Binding]
public class Setup
{
[BeforeScenario("setup_scenario")]
public static void BeforeAppScenario()
{
UILoader.General.StartApplication();
}
[AfterScenario("setup_scenario")]
public static void AfterAppScenario()
{
UILoader.General.CloseApplication();
}
[BeforeFeature("setup_feature")]
public static void BeforeAppFeature()
{
UILoader.General.StartApplication();
}
[AfterFeature("setup_feature")]
public static void AfterAppFeature()
{
UILoader.General.CloseApplication();
}
}
Run Code Online (Sandbox Code Playgroud)
StartApplication/ CloseApplication使用Coded UI Test Builder记录并自动生成:
public void StartApplication()
{
// Launch '%ProgramFiles%\...
ApplicationUnderTest Application = ApplicationUnderTest.Launch(this.StartApplicationParams.ExePath, this.StartApplicationParams.AlternateExePath);
}
public class StartApplicationParams
{
public string ExePath = "C:\\Program Files..."
public string AlternateExePath = "%ProgramFiles%\\..."
}
Run Code Online (Sandbox Code Playgroud)
值得注意的是:我对SpecFlow很新.我无法弄清楚为什么我的测试失败[BeforeFeature]并且工作正常[BeforeScenario].
如果有人可以帮我解决这个问题,那将会很棒.谢谢!
ole*_*gvs 16
我最近遇到了类似的问题.不确定这是否仍然可以帮助你,但它可能适用于偶然发现这个问题的人.
要使BeforeFeature\AfterFeature工作,需要对功能本身进行标记,仅标记特定方案将不起作用.
您的功能文件应如下所示:
@setup_feature
Feature: Name Of Your Feature
@setup_scenario
Scenario: ...
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8187 次 |
| 最近记录: |