How to run multiple cucumber runners from maven command line - maven

I've 2 CI flows , which flow needs to run it's own cucumber runner
RunnerATest
RunnerBTest
I'm using maven command line to run the tests (mvn test)
Is there a way to select a specific Runner from command line ?
Thanks

Maven Surefire Plugin - Running a Single Test
During development, you may run a single test class repeatedly. To run this through Maven, set the test property to a specific test case.
mvn -Dtest=TestCircle test
So you'd do just that. mvn -Dtest=RunnerATest test.

Related

Run tests located within a fat maven jar?

I have a maven project which is a test harness including tests.
The tests can be run using surefire, within intelliJ. And the IDE states the command line it is running in order to do this:
java
-Dmaven.multiModuleProjectDirectory=...
"-Dmaven.home=...
"-Dclassworlds.conf=...
"-Dmaven.ext.class.path=...
"-javaagent:...
-Didea.version=...
install
If I put the jar on another machine, and wish to run the tests contained within it (ideally with surefire plugin) should I be aiming to construct a similar command line as to the above, or run something like mvn test {jar name} or mvn surefire:test {jar name}

Maven how to show Junit test like on Eclipse IDE

I would like to run Junit tests via maven command like having the test result
with the same graphical message that I can see using Eclipse IDE.
For example, if I run Junit test via Eclipse I can see this tree image:
But, if I run the same tests via maven command line, I can see only the grand total result without details.
For example:
There is a way to run maven command line tests and receive the test result like Eclipse IDE?
I use surefire plugin on my project.
Thanks in advance.

How to skip cucumber tests during build & deployment when unit test runs but after deployment it should run cucumber tests via Jenkins - Maven

I have a build project in which i implemented Cucumber BDD and wrote features file and test classes. Now, what i want is that during build & deployment in Jenkins pipeline, all Unit tests should get executed but not the Cucumber tests i.e. Integration tests. As soon as deployment is completed then these cucumber tests should get executed. How we can achieve that?
Is there any way to skip cucumber test during the deployment but after the deployment completion it should execute them?
You can tag your tests with annotations as #Deploy and #AfterDeploy,
To maven deployment script, you can add following script :
-Dcucumber.options="--tags #Deploy"
For the tests after deployment you can use following :
-Dcucumber.options="--tags #AfterDeploy"

Maven run command for specific test suite

i am trying to build maven command to run specific test:
i want to be able to execute this:
mvn test
mvn integration
mvn specificdata
so each test will go into a folder and run the suite
src/test
src/integration
src/specificdata
mvn test works with the test folder but when i run
mvn specificdata i get
[ERROR] Unknown life-cycle phase "specificdata".
same for integration
how can i make mvn run these tests independently?
This cannot be done in the way you describe it.
test is a phase and as such, part of the standard lifecycle. Calling mvn test does not only run tests, but executes the phases before test as well.
The standard lifecycle also offers phases for integration tests, esp. integration-test. Integration tests are usually put into src/test as well and distinguished by a naming convention. But beware: Calling mvn integration-test will call all previous phases (including test, compileetc.) as well.
https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html

Exclude testng tests while building in jenkins

I have a test which consists of both junit test and testng tests. It works fine when i run 'mvn test' from parent pom, but testng tests fail while building in jenkins. I need a way to skip testng tests from running in jenkins.
You said you use jenkins so i assume that you are using maven plugin :
Have you tried to skip test cases in your Maven run? Use the code below in maven properties section of maven plugin:
maven.test.failure.ignore=true
Or
please use below code in properties section of maven plugin to skip the test cases
skipTests=true
Hope this helps
It's better to set it up via runtime in Jenkins' job configuration:
Invoke Top Level Maven -> Advanced.
Add maven.test.skip=true
Once the tests are OK, just remove this line.
You can disable test execution in runtime as well:
mvn -Dmaven.test.skip=true

Resources