Serenity-core: Serenity JVM Runner

Created on 25 Jul 2021  ·  5Comments  ·  Source: serenity-bdd/serenity-core

I have a sample serenity project which run as expected when I run on maven. This is my runner class -https://github.com/dineshbalajibingo/SerenityBDD/blob/develop/src/test/java/runner/TestRunner.java

Now I need to make an executable JAR on this project (a trivial one). So I have a runner with main() method here -https://github.com/dineshbalajibingo/SerenityBDD/blob/develop/src/main/java/runner/TestRunner.java.

In POM.XML, I have added assembly plugin and it create a super fat jar which solves my issue.

Now when I run main method it run as cucumber tests. Is there a way I can run Serenity test instead of cucumber test when I run the JAR.

question

Most helpful comment

This is not trivial at all and not currently supported out-of-the-box.

All 5 comments

Hi, I am also facing a similar issue where I cannot invoke serenity runner class from cmd line when jar is created for project. Is there a way?

Below is the log of my run from cmd promt when I run main() method. This is running cucumber and I need serenity

C:\Users\XXX\Desktop\New folder>java -jar TestProject-1.0-SNAPSHOT-jar-with-dependencies.jar

@Smoke
Scenario Outline: Submit message via the contactUs form ←[90m# features//Test.feature:18←[0m
19:36:01.887 [main] DEBUG n.t.c.u.PropertiesFileLocalPreferences - environments.default.webdriver.base.url=https://webdriveruniversity.com
19:36:01.902 [main] DEBUG n.t.c.u.PropertiesFileLocalPreferences - environments.default.webdriver.base.url=https://webdriveruniversity.com
Printing 1
←[32mGiven ←[0m←[32muser access the webdriveruniversity.com←[0m ←[90m# steps.ContactUsSteps.user_access_the_webdriveruniversity_com()←[0m
Printing 2
←[32mWhen ←[0m←[32mclicks on the ContactUs Form link←[0m ←[90m# steps.ContactUsSteps.clicks_on_the_contact_us_form_link()←[0m

@Smoke
Scenario Outline: Submit message via the contactUs form ←[90m# features//contactUs.feature:18←[0m
Printing 1
←[32mGiven ←[0m←[32muser access the webdriveruniversity.com←[0m ←[90m# steps.ContactUsSteps.user_access_the_webdriveruniversity_com()←[0m
Printing 2
←[32mWhen ←[0m←[32mclicks on the ContactUs Form link←[0m ←[90m# steps.ContactUsSteps.clicks_on_the_contact_us_form_link()←[0m

2 Scenarios (←[32m2 passed←[0m)
4 Steps (←[32m4 passed←[0m)
0m1.071s

←[32m←[1m┌───────────────────────────────────────────────────────────────────────────────────┐←[0m
←[32m←[1m│←[0m Share your Cucumber Report with your team at ←[36m←[1m←[4mhttps://reports.cucumber.io←[0m ←[32m←[1m│←[0m
←[32m←[1m│←[0m Activate publishing with one of the following: ←[32m←[1m│←[0m
←[32m←[1m│←[0m ←[32m←[1m│←[0m
←[32m←[1m│←[0m src/test/resources/cucumber.properties: ←[36mcucumber.publish.enabled←[0m=←[36mtrue←[0m ←[32m←[1m│←[0m
←[32m←[1m│←[0m src/test/resources/junit-platform.properties: ←[36mcucumber.publish.enabled←[0m=←[36mtrue←[0m ←[32m←[1m│←[0m
←[32m←[1m│←[0m Environment variable: ←[36mCUCUMBER_PUBLISH_ENABLED←[0m=←[36mtrue←[0m ←[32m←[1m│←[0m
←[32m←[1m│←[0m JUnit: ←[36m@CucumberOptions←[0m(publish = ←[36mtrue←[0m) ←[32m←[1m│←[0m
←[32m←[1m│←[0m ←[32m←[1m│←[0m
←[32m←[1m│←[0m More information at ←[36mhttps://reports.cucumber.io/docs/cucumber-jvm←[0m ←[32m←[1m│←[0m
←[32m←[1m│←[0m ←[32m←[1m│←[0m
←[32m←[1m│←[0m Disable this message with one of the following: ←[32m←[1m│←[0m
←[32m←[1m│←[0m ←[32m←[1m│←[0m
←[32m←[1m│←[0m src/test/resources/cucumber.properties: ←[36mcucumber.publish.quiet←[0m=←[36mtrue←[0m ←[32m←[1m│←[0m
←[32m←[1m│←[0m src/test/resources/junit-platform.properties: ←[36mcucumber.publish.quiet←[0m=←[36mtrue←[0m ←[32m←[1m│←[0m
←[32m←[1m└───────────────────────────────────────────────────────────────────────────────────┘←[0m
Ignore exit

This is not trivial at all and not currently supported out-of-the-box.

Thanks for your reply @wakaleo Is there a work around available ? Any pointers you have on this ?

You would need to write a wrapper around the JUnit runner classes - have a look in the JUnit APIs on how to run JUnit programmatically.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

knludi picture knludi  ·  4Comments

scormaq picture scormaq  ·  3Comments

aquadrehz picture aquadrehz  ·  5Comments

vikramvi picture vikramvi  ·  7Comments

gkushang picture gkushang  ·  4Comments