Can you run a test for a single method only, not a whole class? Ideally from the command line.
e.g. for a class:
public class TestClass extends Unittest {
@Test
public void test1_shouldbeRun() {
}
@Test
public void test2_shouldNotBeRun() {
}
}
I only want to run the method "test1_shouldBeRun".
I do not think if that is natively supported by JUnit. However, you have some alternatives:
@Ignore
annotation helps you.TestSuit
and an Ant task that can make this for you.It is possible when you use the surefire plugin [1]:
mvn -Dtest=TestClass#test1_shouldbeRun test
[1] http://maven.apache.org/surefire/maven-surefire-plugin/examples/single-test.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With