Kbii
Kbii

Reputation: 185

Start single Serenity scenario from command line

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.

How can I run a single scenario of this suite using mvn command line?

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.

Code snipplet:

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

Upvotes: 1

Views: 1243

Answers (1)

Satish
Satish

Reputation: 1065

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

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

mvn -Dit.test=ITCircle#test* verify

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

Upvotes: 0

Related Questions