Serenity测试无法在Serenity参数化运行器中运行。

huangapple go评论117阅读模式
英文:

Serenity test not running with Serenity Parameterized Runner

问题

我正在尝试使用参数化运行器运行 Serenity 测试,

  1. @RunWith(SerenityParameterizedRunner.class)
  2. public class CloneViewTest {
  3. String val;
  4. public CloneViewTest(String testData) {
  5. val = testData;
  6. }
  7. protected Actor james = Actor.named("James");
  8. @Managed
  9. protected WebDriver driver;
  10. @Before
  11. public void jamesCanBrowseTheWeb() {
  12. james.can(BrowseTheWeb.with(driver));
  13. }
  14. @TestData
  15. public Collection<Object[]> testdata() {
  16. return Arrays.asList(new Object[][]{
  17. {"cats"},
  18. {"dogs"},
  19. {"ferrets"},
  20. {"rabbits"},
  21. {"canaries"}
  22. });
  23. }
  24. @Test
  25. public void should_be_able_to_clone_views() {
  26. james.attemptsTo(Open.browserOn().the(Column_dictionaryPage.class));
  27. }
  28. }

问题是,无论何时我使用 mvn clean verify 运行此测试,测试都会成功,但不会运行任何测试。同时日志显示测试被跳过,

  1. [INFO] --- maven-surefire-plugin:2.22.1:test (default-test) @ -Automation ---
  2. [INFO] Tests are skipped.
  3. [INFO]
  4. [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ -Automation ---
  5. [INFO] Building jar: C:\Users\Hamza Y\IdeaProjects\-Assignment-Serenity-Screenplay\target\-Automation-1.0.0-SNAPSHOT.jar
  6. [INFO]
  7. [INFO] --- maven-failsafe-plugin:3.0.0-M5:integration-test (default) @ -Automation ---
  8. [INFO]
  9. [INFO] --- serenity-maven-plugin:2.3.4:aggregate (serenity-reports) @ -Automation ---
  10. [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/
  11. [INFO] -----------------------------------------
  12. [INFO] SERENITY TESTS : SUCCESS
  13. [INFO] -----------------------------------------
  14. [INFO] | Tests executed | 0
  15. [INFO] | Tests passed | 0
  16. [INFO] | Tests failed | 0
  17. [INFO] | Tests with errors | 0
  18. [INFO] | Tests compromised | 0
  19. [INFO] | Tests pending | 0
  20. [INFO] | Tests ignored/skipped | 0
  21. [INFO] ------------------------ | --------------
  22. [INFO] | Total Duration | 000ms
  23. [INFO] | Fastest test took | 000ms
  24. [INFO] | Slowest test took | 000ms
  25. [INFO] -----------------------------------------

同时,正如日志中所示,没有测试被执行、失败或跳过。在这里可能的问题是什么?

英文:

I am trying to run serenity test with parameterized runner,

  1. @RunWith(SerenityParameterizedRunner.class)
  2. public class CloneViewTest {
  3. String val;
  4. public CloneViewTest(String testData) {
  5. val = testData;
  6. }
  7. protected Actor james = Actor.named(&quot;James&quot;);
  8. @Managed
  9. protected WebDriver driver;
  10. @Before
  11. public void jamesCanBrowseTheWeb() {
  12. james.can(BrowseTheWeb.with(driver));
  13. }
  14. @TestData
  15. public Collection&lt;Object[]&gt; testdata() {
  16. return Arrays.asList(new Object[][]{
  17. {&quot;cats&quot;},
  18. {&quot;dogs&quot;},
  19. {&quot;ferrets&quot;},
  20. {&quot;rabbits&quot;},
  21. {&quot;canaries&quot;}
  22. });
  23. }
  24. @Test
  25. public void should_be_able_to_clone_views() {
  26. james.attemptsTo(Open.browserOn().the(Column_dictionaryPage.class));
  27. }
  28. }

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

  1. [INFO] --- maven-surefire-plugin:2.22.1:test (default-test) @ -Automation ---
  2. [INFO] Tests are skipped.
  3. [INFO]
  4. [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ -Automation ---
  5. [INFO] Building jar: C:\Users\Hamza Y\IdeaProjects\-Assignment-Serenity-Screenplay\target\-Automation-1.0.0-SNAPSHOT.jar
  6. [INFO]
  7. [INFO] --- maven-failsafe-plugin:3.0.0-M5:integration-test (default) @ -Automation ---
  8. [INFO]
  9. [INFO] --- serenity-maven-plugin:2.3.4:aggregate (serenity-reports) @ -Automation ---
  10. [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
  11. /
  12. [INFO] -----------------------------------------
  13. [INFO] SERENITY TESTS : SUCCESS
  14. [INFO] -----------------------------------------
  15. [INFO] | Tests executed | 0
  16. [INFO] | Tests passed | 0
  17. [INFO] | Tests failed | 0
  18. [INFO] | Tests with errors | 0
  19. [INFO] | Tests compromised | 0
  20. [INFO] | Tests pending | 0
  21. [INFO] | Tests ignored/skipped | 0
  22. [INFO] ------------------------ | --------------
  23. [INFO] | Total Duration | 000ms
  24. [INFO] | Fastest test took | 000ms
  25. [INFO] | Slowest test took | 000ms
  26. [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.

huangapple
  • 本文由 发表于 2020年9月25日 18:19:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/64062212.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定