maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stephen Connolly <stephen.alan.conno...@gmail.com>
Subject Re: Surefire unable to find "bar" test method when passed -Dtest=Foo#bar
Date Tue, 01 May 2012 16:31:23 GMT
ahem...

are you running on a unix system?

you do know # is the comment start marker for most unix shells

you'd need to escape it with \ or quote the entire -D....

On 1 May 2012 16:24, Laird Nelson <ljnelson@gmail.com> wrote:

> 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
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message