在创建新场景时,我只想测试我目前正在使用的场景。为此,我想Meta: @skip
在我的场景之前使用标签。我发现我必须使用embedder
来配置使用的元标记,所以我尝试了:
configuredEmbedder().useMetaFilters(Arrays.asList("-skip"));
但实际上这仍然对我的测试场景没有影响。我在我的SerenityStories
测试套件定义的构造函数中使用了它。这是这个类的完整代码:
public class AcceptanceTestSuite extends SerenityStories {
@Managed
WebDriver driver;
public AcceptanceTestSuite() {
System.setProperty("webdriver.chrome.driver", "D:/files/chromedriver/chromedriver.exe");
System.setProperty("chrome.switches", "--lang=en");
System.setProperty("restart.browser.each.scenario", "true");
configuredEmbedder().useMetaFilters(Arrays.asList("-skip"));
runSerenity().withDriver("chrome");
}
@Override
public Configuration configuration() {
Configuration configuration = super.configuration();
Keywords keywords = new LocalizedKeywords(DEFAULTSTORYLANGUAGE);
Properties properties = configuration.storyReporterBuilder().viewResources();
properties.setProperty("encoding", "UTF-8");
configuration.useKeywords(keywords)
.useStoryParser(new RegexStoryParser(keywords, new ExamplesTableFactory(new LoadFromClasspath(this.getClass()))))
.useStoryLoader(new UTF8StoryLoader()).useStepCollector(new MarkUnmatchedStepsAsPending(keywords))
.useDefaultStoryReporter(new ConsoleOutput(keywords)).storyReporterBuilder().withKeywords(keywords).withViewResources(properties);
return configuration;
}
}
这是错误的地方还是我错过了什么?仍然执行所有场景。
编辑:
我改变了以下课程,现在我认为它“有效”
public AcceptanceTestSuite() {
System.setProperty("webdriver.chrome.driver", "D:/files/chromedriver/chromedriver.exe");
System.setProperty("chrome.switches", "--lang=de");
System.setProperty("restart.browser.each.scenario", "true");
this.useEmbedder(configuredEmbedder());
runSerenity().withDriver("chrome");
}
@Override
public Embedder configuredEmbedder() {
final Embedder embedder = new Embedder();
embedder.embedderControls()
.useThreads(1)
.doGenerateViewAfterStories(true)
.doIgnoreFailureInStories(false)
.doIgnoreFailureInView(false)
.doVerboseFailures(true);
final Configuration configuration = configuration();
embedder.useConfiguration(configuration);
embedder.useStepsFactory(stepsFactory());
embedder.useMetaFilters(Arrays.asList("-skip"));
return embedder;
}
但现在我收到了消息 [pool-1-thread-1] INFO net.serenitybdd.core.Serenity - TEST IGNORED
,但场景仍在执行。只有在结果页面中,我才能获得此场景被忽略(但仍被执行)的信息。有没有办法跳过这个场景,所以它不会运行?