I have a test class; let's call it TestCaseFoo.

When I run surefire:test with no value for the "test" property, this class
is found and all of its test methods execute.

I would like to run just one of those methods.

So I tried invoking Maven like this:

mvn clean test -Dtest=TestCaseFoo#testBar

...where my test case has a method like this:

@Test
public void testBar() {
  // here is where the magic happens
}

I get this error:

initializationError(org.junit.runner.manipulation.Filter)  Time elapsed:
0.004 sec  <<< ERROR!
java.lang.Exception: No tests found matching Method
testBar(com.fizbaw.TestCaseFoo) from
org.junit.internal.requests.ClassRequest@624b035d
at
org.junit.internal.requests.FilterRequest.getRunner(FilterRequest.java:37)
at
org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:227)
at
org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:134)
at
org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:113)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)

Note in particular the odd method signature, or at least the output that
says testBar(com.fizbaw.TestCaseFoo).  JUnit methods must have zero
parameters.  I'm not sure what's going on here.

I am using JUnit 4.10 and Surefire 2.12.

Best,
Laird

-- 
http://about.me/lairdnelson

Reply via email to