从命令行启动单个 Serenity 场景

Start single Serenity scenario from command line

我的团队获得了网络应用程序的所有权。测试是用 junit 套件和宁静编写的。好东西,有很好的测试覆盖率。当您需要 运行 仍然失败的单个 test/scenario 并且您需要等待 >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
    }

首先确认您使用的是支持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了解更多详情。