从命令行启动单个

从命令行启动单个

本文介绍了从命令行启动单个 Serenity 场景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的团队获得了一个网络应用程序的所有权.测试是用 junit 套件和宁静编写的.好东西,有很好的测试覆盖率.当您需要运行仍然失败的单个测试/场景并且需要等待 30 分钟以上才能运行所有内容时,问题就来了.

My team received ownership of a webapp. Tests are written with junit suites and serenity. Good things, there a good test coverage. Problem come when you need to run that single test/scenario that is still failing and you need to wait >30min to run everything.

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

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

From code editor, it's hard to start single scenario as both suite and test classes contains important initialization code.I've also tried argument '-Dtest=T1Test#T1Scenario1' without success.

代码片段:

   @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

Just confirm first that your using supported surefire and junit version. For more details refer https://maven.apache.org/surefire/maven-surefire-plugin/examples/single-test.html

如果您使用 maven 故障安全插件,则语法会略有不同.类似这样的

In case your using maven failsafe plugin then the syntax will vary little bit. Something like this

mvn -Dit.test=ITCircle#test* verify

参考 https://maven.apache.org/surefire/maven-failsafe-plugin/examples/single-test.html 了解更多详情.

Refer https://maven.apache.org/surefire/maven-failsafe-plugin/examples/single-test.html for more details.

这篇关于从命令行启动单个 Serenity 场景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 20:16