从命令行启动单个 Serenity 场景

编程入门 行业动态 更新时间:2024-10-28 08:27:30
本文介绍了从命令行启动单个 Serenity 场景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我的团队获得了一个网络应用程序的所有权.测试是用 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/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/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/surefire/maven-failsafe-plugin/examples/single-test.html 了解更多详情.

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

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

更多推荐

[db:关键词]

本文发布于:2023-04-30 22:25:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1401087.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:命令行   场景   Serenity

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!