1

我的团队获得了 webapp 的所有权。测试是用junit 套件和serenity 编写的。好东西,有很好的测试覆盖率。当您需要运行仍然失败的单个测试/场景并且您需要等待 >30 分钟才能运行所有内容时,问题就来了。

如何使用 mvn 命令行运行此套件的单个场景?

从代码编辑器中,很难启动单个场景,因为套件和测试类都包含重要的初始化代码。我也尝试过参数 '-Dtest=T1Test#T1Scenario1' 但没有成功。

代码片段:

   @RunWith(Suite.class)
    @Suite.SuiteClasses({
            UserConfigASuite.class,
            UserConfigBSuite.class,
            UserConfigCSuite.class
    })
    public class AllTestSuite {
    }

    @RunWith(Suite.class)
    @Suite.SuiteClasses({
        T1Test.class,
        T2Test.class,
        //... Lots of other tests
    })public class UserConfigASuite {
      @BeforeClass
      public static void beforeClass() {
          //Required init code
      }

    @AfterClass
    public static void afterClass() {
        //Cleanup after test suite
      }
    }

    @RunWith(SerenityRunner.class)
    public class T1Test {

      @Test
      @Title("T1: scenario 1")
      public void T1Scenario1() {

      } 

      //... Lots of other scenarios
    }
4

1 回答 1

1

只需先确认您使用受支持的surefire 和junit 版本。有关更多详细信息,请参阅https://maven.apache.org/surefire/maven-surefire-plugin/examples/single-test.html

如果您使用 maven 故障安全插件,那么语法会有所不同。像这样的东西

mvn -Dit.test=ITCircle#test* verify

有关详细信息,请参阅https://maven.apache.org/surefire/maven-failsafe-plugin/examples/single-test.html

于 2018-11-22T15:06:11.883 回答