英文:
Serenity test not running with Serenity Parameterized Runner
问题
我正在尝试使用参数化运行器运行 Serenity 测试,
@RunWith(SerenityParameterizedRunner.class)
public class CloneViewTest {
String val;
public CloneViewTest(String testData) {
val = testData;
}
protected Actor james = Actor.named("James");
@Managed
protected WebDriver driver;
@Before
public void jamesCanBrowseTheWeb() {
james.can(BrowseTheWeb.with(driver));
}
@TestData
public Collection<Object[]> testdata() {
return Arrays.asList(new Object[][]{
{"cats"},
{"dogs"},
{"ferrets"},
{"rabbits"},
{"canaries"}
});
}
@Test
public void should_be_able_to_clone_views() {
james.attemptsTo(Open.browserOn().the(Column_dictionaryPage.class));
}
}
问题是,无论何时我使用 mvn clean verify
运行此测试,测试都会成功,但不会运行任何测试。同时日志显示测试被跳过,
[INFO] --- maven-surefire-plugin:2.22.1:test (default-test) @ -Automation ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ -Automation ---
[INFO] Building jar: C:\Users\Hamza Y\IdeaProjects\-Assignment-Serenity-Screenplay\target\-Automation-1.0.0-SNAPSHOT.jar
[INFO]
[INFO] --- maven-failsafe-plugin:3.0.0-M5:integration-test (default) @ -Automation ---
[INFO]
[INFO] --- serenity-maven-plugin:2.3.4:aggregate (serenity-reports) @ -Automation ---
[INFO] Test results for 0 tests generated in 1.7 secs in directory: file:/C:/Users/Hamza%20Y/IdeaProjects/-Assignment-Serenity-Screenplay/target/site/serenity/
[INFO] -----------------------------------------
[INFO] SERENITY TESTS : SUCCESS
[INFO] -----------------------------------------
[INFO] | Tests executed | 0
[INFO] | Tests passed | 0
[INFO] | Tests failed | 0
[INFO] | Tests with errors | 0
[INFO] | Tests compromised | 0
[INFO] | Tests pending | 0
[INFO] | Tests ignored/skipped | 0
[INFO] ------------------------ | --------------
[INFO] | Total Duration | 000ms
[INFO] | Fastest test took | 000ms
[INFO] | Slowest test took | 000ms
[INFO] -----------------------------------------
同时,正如日志中所示,没有测试被执行、失败或跳过。在这里可能的问题是什么?
英文:
I am trying to run serenity test with parameterized runner,
@RunWith(SerenityParameterizedRunner.class)
public class CloneViewTest {
String val;
public CloneViewTest(String testData) {
val = testData;
}
protected Actor james = Actor.named("James");
@Managed
protected WebDriver driver;
@Before
public void jamesCanBrowseTheWeb() {
james.can(BrowseTheWeb.with(driver));
}
@TestData
public Collection<Object[]> testdata() {
return Arrays.asList(new Object[][]{
{"cats"},
{"dogs"},
{"ferrets"},
{"rabbits"},
{"canaries"}
});
}
@Test
public void should_be_able_to_clone_views() {
james.attemptsTo(Open.browserOn().the(Column_dictionaryPage.class));
}
}
The problem is whenever is run this test using mvn clean verify
Test is successful but no test is run. Also log shows skipping tests
[INFO] --- maven-surefire-plugin:2.22.1:test (default-test) @ -Automation ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ -Automation ---
[INFO] Building jar: C:\Users\Hamza Y\IdeaProjects\-Assignment-Serenity-Screenplay\target\-Automation-1.0.0-SNAPSHOT.jar
[INFO]
[INFO] --- maven-failsafe-plugin:3.0.0-M5:integration-test (default) @ -Automation ---
[INFO]
[INFO] --- serenity-maven-plugin:2.3.4:aggregate (serenity-reports) @ -Automation ---
[INFO] Test results for 0 tests generated in 1.7 secs in directory: file:/C:/Users/Hamza%20Y/IdeaProjects/-Assignment-Serenity-Screenplay/target/site/serenity
/
[INFO] -----------------------------------------
[INFO] SERENITY TESTS : SUCCESS
[INFO] -----------------------------------------
[INFO] | Tests executed | 0
[INFO] | Tests passed | 0
[INFO] | Tests failed | 0
[INFO] | Tests with errors | 0
[INFO] | Tests compromised | 0
[INFO] | Tests pending | 0
[INFO] | Tests ignored/skipped | 0
[INFO] ------------------------ | --------------
[INFO] | Total Duration | 000ms
[INFO] | Fastest test took | 000ms
[INFO] | Slowest test took | 000ms
[INFO] -----------------------------------------
Also as shown in log no test is executed, failed or skipped. What could be the problem here?
答案1
得分: 2
你很可能使用了错误的类名。考虑到你正在使用默认配置,verify
将会运行带有类似 *IT.java
模式的测试。
将你的类名改为 CloneViewTestIT
,然后再次尝试。
英文:
You have most likely the wrong class name. Given you are using the default config, verify
will run tests with patterns like *IT.java
https://maven.apache.org/surefire/maven-failsafe-plugin/examples/inclusion-exclusion.html
rename you class to CloneViewTestIT
and try again.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论