TestNG surefire, run the maven command line package

Is it possible to run a predefined set of xml from the command line via maven?

I can run a class or a specific test. But I can not run the package.

Here is what I run from the command line: ->

mvn -Dtest=TestCircle#mytest -Denvironment=test -Dbrowser=firefox -DscreenShotDirectory=/Users/jeremy/temp test 

I have a specific set that works well through intelliJ, but I'm not sure how to call the suite.xml file.

Or, for example, after running the tests, testng creates a file with the testng error, which is configured to restart all failed tests.

Using mvn, how do I start this test suite.

+6
source share
3 answers

This answer gave me what I was looking for, namely the ability to pass in the command line the name of the package I want to run:

http://www.vazzolla.com/2013/03/how-to-select-which-testng-suites-to-run-in-maven-surefire-plugin/

Briefly add the following to the maven-surfire-plugin stanza of your pom.xml:

 <suiteXmlFiles> <suiteXmlFile>${suiteXmlFile}</suiteXmlFile> </suiteXmlFiles> 

Then you can specify the desired xml file of the testng file on the command line:

 mvn clean install test -DsuiteXmlFile=testngSuite.xml 
+14
source

Usually you don’t need anything special with TestNG. Just use the maven-surefire plugin:

  <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.12</version> </plugin> 

and based on this, all tests must be performed that must be properly annotated. Ah, of course, you need a dependency on TestNG as follows:

 <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>6.5.2</version> <scope>test</scope> </dependency> 

As a rule, I will no longer create test objects, because this is what you need to support, which is often skipped for updates, etc. Just use annotations.

If you need to run a specific test suite, simply define the testng.xml file in src / test / resources and upgrade the maven-surefire plugin accordingly.

  <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.12</version> <configuration> <suiteXmlFiles> <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile> </suiteXmlFiles> </configuration> </plugin> 
+5
source
 <build> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.12</version> <configuration> <suiteXmlFiles> <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile> </suiteXmlFiles> </configuration> </plugin> </build> 

it worked for me.

+4
source

Source: https://habr.com/ru/post/914585/


All Articles