------ Running a Single Test ------ Allan Ramirez Olivier Lamy ------ 2012-02-28 ------ ~~ Licensed to the Apache Software Foundation (ASF) under one ~~ or more contributor license agreements. See the NOTICE file ~~ distributed with this work for additional information ~~ regarding copyright ownership. The ASF licenses this file ~~ to you under the Apache License, Version 2.0 (the ~~ "License"); you may not use this file except in compliance ~~ with the License. You may obtain a copy of the License at ~~ ~~ http://www.apache.org/licenses/LICENSE-2.0 ~~ ~~ Unless required by applicable law or agreed to in writing, ~~ software distributed under the License is distributed on an ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ~~ KIND, either express or implied. See the License for the ~~ specific language governing permissions and limitations ~~ under the License. ~~ NOTE: For help with the syntax of this file, see: ~~ http://maven.apache.org/doxia/references/apt-format.html Running a Single Test #{if}(${project.artifactId}=="maven-surefire-plugin") During development, you may run a single test class repeatedly. To run this through Maven, set the <<>> property to a specific test case. +---+ mvn -Dtest=TestCircle test +---+ The value for the <<>> parameter is the name of the test class (without the extension; we'll strip off the extension if you accidentally provide one). #{else} During development, you may run a single test class repeatedly. To run this through Maven, set the <<>> property to a specific test case. +---+ mvn -Dit.test=ITCircle verify +---+ The value for the <<>> parameter is the name of the test class (without the extension; we'll strip off the extension if you accidentally provide one). #{end} You may also use patterns to run a number of tests: #{if}(${project.artifactId}=="maven-surefire-plugin") +---+ mvn -Dtest=TestCi*le test +---+ #{else} +---+ mvn -Dit.test=ITCi*le verify +---+ #{end} And you may use multiple names/patterns, separated by commas: #{if}(${project.artifactId}=="maven-surefire-plugin") +---+ mvn -Dtest=TestSquare,TestCi*le test +---+ #{else} +---+ mvn -Dit.test=ITSquare,ITCi*le verify +---+ #{end} Running a set of methods in a Single Test Class With version 2.7.3, you can run only n tests in a single Test Class. << NOTE : it's supported for junit 4.x and TestNG. >> You must use the following syntax #{if}(${project.artifactId}=="maven-surefire-plugin") +---+ mvn -Dtest=TestCircle#mytest test +---+ #{else} +---+ mvn -Dit.test=ITCircle#mytest verify +---+ #{end} You can use patterns too #{if}(${project.artifactId}=="maven-surefire-plugin") +---+ mvn -Dtest=TestCircle#test* test +---+ #{else} +---+ mvn -Dit.test=ITCircle#test* verify +---+ #{end} As of surefire 2.12.1, you can select multiple methods (JUnit4X only at this time, patches welcome) #{if}(${project.artifactId}=="maven-surefire-plugin") +---+ mvn -Dtest=TestCircle#testOne+testTwo test +---+ #{else} +---+ mvn -Dit.test=ITCircle#test* verify +---+ #{end}