Maven Surefire Plugin: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
=External=
=External=


* http://maven.apache.org/surefire/maven-surefire-plugin/
* http://maven.apache.org/surefire/maven-surefire-report-plugin/
* http://maven.apache.org/surefire/maven-surefire-report-plugin/


Line 6: Line 7:


* [[Maven#Plugin|Maven]]
* [[Maven#Plugin|Maven]]
* [[Maven_failsafe_Plugin|failsafe Plugin]]
=Overview=
Executes unit tests.


=Configuration Example=
=Configuration Example=


<pre>
<syntaxhighlight lang='xml'>
<plugin>
<plugin>
     <groupId>org.apache.maven.plugins</groupId>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-surefire-plugin</artifactId>
     <artifactId>maven-surefire-plugin</artifactId>
    <version>2.19.1</version>
     <configuration>
     <configuration>
         <systemProperties>
         <systemProperties>
Line 22: Line 29:
   </configuration>
   </configuration>
</plugin>
</plugin>
</pre>
</syntaxhighlight>
 
Also see [[Testing_with_Gradle_Java_Plugin#Passing_System_Properties_to_Tests|Passing system properties to Gradle Tests]].


=Attaching the Plugin to a Specific Phase=
=Attaching the Plugin to a Specific Phase=


<executions>
{{Internal|Maven_Concepts#Plugin_Execution|Plugin Execution}}
                    <execution>
                        <id>attach-sources</id>
                        <phase>package</phase>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>


=Procedures=
=Procedures=
Line 50: Line 51:
* Single Test Example: http://maven.apache.org/plugins/maven-surefire-plugin/examples/single-test.html
* Single Test Example: http://maven.apache.org/plugins/maven-surefire-plugin/examples/single-test.html


<pre>
mvn -Dtest=TestCircle test
mvn -Dtest=TestCircle test
</pre>


Works for both JUnit and TestNG.
Works for both JUnit and TestNG.
==Do Not Run Tests==
mvn -Dmaven.test.skip=true ...

Latest revision as of 01:40, 7 November 2019

External

Internal

Overview

Executes unit tests.

Configuration Example

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.19.1</version>
    <configuration>
        <systemProperties>
            <property>
                <name>basedir</name>
                <value>${basedir}</value>
            </property>
        </systemProperties>
   </configuration>
</plugin>

Also see Passing system properties to Gradle Tests.

Attaching the Plugin to a Specific Phase

Plugin Execution

Procedures

Debugging Tests

mvn -Dmaven.surefire.debug="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005" test

Running Individual Tests

mvn -Dtest=TestCircle test

Works for both JUnit and TestNG.

Do Not Run Tests

mvn -Dmaven.test.skip=true ...