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

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

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(&quot;James&quot;);
    @Managed
    protected WebDriver driver;

    @Before
    public void jamesCanBrowseTheWeb() {
        james.can(BrowseTheWeb.with(driver));
    }

    @TestData
    public Collection&lt;Object[]&gt; testdata() {
        return Arrays.asList(new Object[][]{
                {&quot;cats&quot;},
                {&quot;dogs&quot;},
                {&quot;ferrets&quot;},
                {&quot;rabbits&quot;},
                {&quot;canaries&quot;}
        });
        
    }

    @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.

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:

确定