Document directory
- Maven 2
- In Java 1.4
- Maven 1 (by Andrew Glover)
First, I will skip where the idea plug-in is. I will try it later.
Directory
- Maven2 plugin
- Maven 1 plug-in
Maven 2
Maven2 itself supports testng without the need to download any additional plug-ins (except testng itself ).
Current version
The latest and better surefire plug-in is2.4. You can refer to the surefire website here (and here is the special guide for testng ).
Configuration target
Target |
Description |
Test |
Compile and run your test |
Site |
Create your own Maven generation site, including your testng report output |
Attribute
Attribute |
Optional? |
Description |
Includes |
No |
A comma-separated regular expression style, which contains the source code such as. ie **/test *. Java |
Groups |
Yes |
The group name to be tested. If it is empty, all groups are run by default. |
Excludegroups |
Yes |
Comma-separated groups that do not need to be tested. |
Suitexmlfiles |
Yes |
List of file paths separated by commas.(Src/test-data/testng-core.xml, src/test-data/testng-functional.xml) Warning when suitexmlfiles is defined, most other parameters are ignored. |
Threadcount |
Yes |
The number of threads used to run the test. |
Parallel |
Yes |
Whether to run the test in parallel when multiple threads are used. UseTestsTo run each test in your own thread, or useMethodsMake each called method run in different threads. |
In Java 1.4
To be able to use javadoc-style annotations, you must use version 1.4 JVM to run Maven to see the effect. If 1.5 JVM is used to process these javadoc-style annotations, nothing will happen. This issue will be eliminated in the future.
Report example
The surefire report using testng can be viewed here.
Maven testng
Prototype (Martin Gilday)
Martin Gilday has added a new prototype for maven2 to make it easier to use testng. You can find more content in his blog here. However, the basic configurations are listed below.
To create a project that uses the prototype, you just need to create a simple code library and prototype ID.
mvn archetype:create -DgroupId=org.martingilday -DartifactId=test1 -DarchetypeGroupId=org.martingilday -DarchetypeArtifactId=testng-archetype
-DarchetypeVersion=1.0-SNAPSHOT -DremoteRepositories=http://www.martingilday.org/repository/
Of course, you can replace it with your own groudid and artifactid.
Don't forget to come to Martin's blog frequently to see if there are more updates.
Maven 1 (by Andrew Glover)
The testng Maven plug-in is very simple and consists of two targets and a series of optional attributes.
Currently, the plug-in for version 1.1 is bound to the official release of testng. To use this plug-inMaven-testng-plugin-. JarCopy$ Maven_home/pluginsDirectory.
For the latest plug-ins (1.2 on 12/12/05), update yourMaven. Repo. RemoteInHttp://www.vanwardtechnologies.com/repository/Run the following command:Maven Plugin: Download. MAVEN will generate the following content:
Artifactid: |
Maven-testng-plugin |
Groupid: |
Testng |
Version: |
1.2 |
Target
Target |
Description |
Testng |
Run testng |
Testng: JUnit-Report |
Create a JUnit report |
Attribute
Attribute |
Optional? |
Description |
Maven. testng. suitexml. Name |
Yes |
XML file name-default value:Testng. xml |
Maven. testng. suitexml. dir |
Yes |
Directory where the XML file is located. The default value is$ {Basedir}/test/Conf |
Maven. testng. Output. dir |
Yes |
The default report directory. The default value is$ {Maven. Build. dir}/testng-Output |
Maven. testng. Source. dir |
Yes |
For the source code location of 1.4, the default value is$ {Basedir}/test/Java/ |
Maven. testng. Report. dir |
Yes |
The Directory of the JUnit report. The default value is$ {Maven. Build. dir}/testngjunitreport |
The JUnit-style test report generated by using the maven plug-in testng can be viewed here.