我是自动化的新手,我正在尝试使用selenium和jbehave自动化一些UI测试用例。基本测试似乎工作正常。 现在我有一个有两个场景的故事文件,每个场景都有多个文件中定义的步骤。 当我运行这个测试用例时,它会显示出来。
测试被忽略。 测试被忽略了 测试被忽略了 测试被忽略了 测试被忽略。[pool-1-thread-1] INFO net.serenitybdd.core.Serenity - TEST PENDING
我在这里看到了类似的问题,但没有答案。任何人都可以帮我这个吗?
Serenity-bdd:版本1.1.36
更新: 我的文件夹结构就像 测试 爪哇/ ... 账户 脚步 AccountsSteps UserSteps 测试 AccountsTest 为AccountTest UserTest 资源/ ... 账户 测试 accounts_test.story user_test.story
这是我的带有JUnitStory的Testclass。这将查看文件AccountsSteps的步骤并正确执行它。
@RunWith(JUnitReportingRunner.class)
public class AccountsTest extends JUnitStory {
private WebDriver driver = new FirefoxDriver();
@Override
public Configuration configuration() {
return new MostUsefulConfiguration()
.useStoryLoader(new LoadFromClasspath(this.getClass()))
.useStoryReporterBuilder(new StoryReporterBuilder()
.withReporters(new MyStoryReporter())
.withDefaultFormats().withFormats(StoryReporterBuilder.Format.CONSOLE, StoryReporterBuilder.Format.HTML, StoryReporterBuilder.Format.STATS));
}
@Override
public InjectableStepsFactory stepsFactory() {
return new InstanceStepsFactory(configuration(), new AccountsSteps(driver));
}
}
我尝试使用SerenityStories添加如下所示的课程,该课程将查看account / test下的所有故事
@RunWith(JUnitReportingRunner.class)
public class AccountTest extends SerenityStories {
public AccountTest() {
findStoriesIn("**//accounts/test");
}
}
控制台显示该文件夹中的所有故事/方案,但将所有测试显示为已忽略。
答案 0 :(得分:0)
检查构建日志/控制台输出中的单词" pending"。您可能还有尚未实施的步骤。
如果是这样的话,您将收到一条有用的消息,告诉您该方法的外观,例如:
You can implement missing steps with the snippets below:
@Given("^I am landing page$") public void i_am_landing_page() throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
答案 1 :(得分:0)
您必须在下面的代码中指明stepdefinitions路由
import cucumber.api.CucumberOptions;
import cucumber.api.SnippetType;
import net.serenitybdd.cucumber.CucumberWithSerenity;
import org.junit.runner.RunWith;
@RunWith(CucumberWithSerenity.class)
@CucumberOptions(
plugin = {"pretty"},
features = "src/test/resources/features",
glue = "stepdefinitions",
snippets= SnippetType.CAMELCASE )
public class CucumberTestSuite {
}