4

We have a profile created in maven to run our Selenium junit4 type tests and below is the snippet of it without the executions tag.

<profile>
    <id>selenium-tests</id>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>2.11</version>
                <dependencies>
                    <!-- Force using the latest JUnit 47 provider -->
                    <dependency>
                        <groupId>org.apache.maven.surefire</groupId>
                        <artifactId>surefire-junit47</artifactId>
                        <version>2.11</version>
                    </dependency>
                </dependencies>
                <configuration>
                    <parallel>classes</parallel>
                    <threadCount>5</threadCount>
                    <forkMode>pertest</forkMode>
                    <useManifestOnlyJar>false</useManifestOnlyJar>
                    <redirectTestOutputToFile>true</redirectTestOutputToFile>
                    <skip>false</skip>
                    <includes>
                         <include>**/regtests/*.java</include>
                    </includes>
                </configuration>
            </plugin>
        </plugins>
    </build>
</profile>

And my TestClass looks like this.

@RunWith(HTMLSourceDumperJUnit4Runner.class) //Our own Runner
public class MyTestClass extends Assert {

     private int x = 1;
     private int y = 1;

     @Test
     public void testAddition() {
         int z = x + y;
         assertEquals(2, z);
     }

}

When I run this testclass through the failsafe plugin 2.11 with parallel configuration it fails with the following error.

java.lang.Exception: No runnable methods
    at org.junit.runners.BlockJUnit4ClassRunner.validateInstanceMethods(BlockJUnit4ClassRunner.java:171)
    at org.junit.runners.BlockJUnit4ClassRunner.collectInitializationErrors(BlockJUnit4ClassRunner.java:115)
    at org.junit.runners.ParentRunner.validate(ParentRunner.java:269)
    at org.junit.runners.ParentRunner.(ParentRunner.java:66)
    at org.junit.runners.BlockJUnit4ClassRunner.(BlockJUnit4ClassRunner.java:59)
    at org.junit.internal.builders.JUnit4Builder.runnerForClass(JUnit4Builder.java:13)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
    at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)
    at org.junit.runner.Computer.getRunner(Computer.java:38)
    at org.apache.maven.surefire.junitcore.ConfigurableParallelComputer.getRunner(ConfigurableParallelComputer.java:142)
    at org.junit.runner.Computer$1.runnerForClass(Computer.java:29)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
    at org.junit.runners.model.RunnerBuilder.runners(RunnerBuilder.java:93)
    at org.junit.runners.model.RunnerBuilder.runners(RunnerBuilder.java:84)
    at org.junit.runners.Suite.(Suite.java:79)
    at org.junit.runner.Computer.getSuite(Computer.java:26)
    at org.apache.maven.surefire.junitcore.ConfigurableParallelComputer.getSuite(ConfigurableParallelComputer.java:134)
    at org.junit.runner.Request.classes(Request.java:69)
    at org.apache.maven.surefire.junitcore.JUnitCoreWrapper.execute(JUnitCoreWrapper.java:53)
    at org.apache.maven.surefire.junitcore.JUnitCoreProvider.invoke(JUnitCoreProvider.java:140)
    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:188)
    at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:166)
    at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:86)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:101)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:74)

Is there anything I'm missing here. If I'm lagging any information for this post, please post back.

A_Di-Matteo
  • 26,902
  • 7
  • 94
  • 128
raksja
  • 3,969
  • 5
  • 38
  • 44
  • 1
    You're mixing versions too; the surefire-junit47 dependency should follow the failsafe version; 2.11 instead of 2.8 – krosenvold Jan 13 '12 at 08:58
  • Thanks.. I tried this and still showing the same error. I have updated question with the latest tries.. – raksja Jan 14 '12 at 03:25
  • Simply upgrading to surefire 2.11 from 2.10 breaks every unit test I have with errors like yours above -- with or without trying the new parallel stuff. All the tests are valid JUnit 4 type tests that work fine with 2.10 and prior. I've spent a couple hours trying to figure it out, time to wait until surefire 2.12. What I am doing similar is the forkMode, useManifestOnlyJar, and redirectOutputToFile settings. Perhaps try different settings for some or all of those? – Scott Carey Jan 17 '12 at 04:12
  • @Scott This should be fixed in 2.12, coming 'soon' – krosenvold Jan 25 '12 at 08:36

2 Answers2

4

According the the maven docs on the plugin, specifically the <includes> tag. The test class name patterns are: **/IT*.java, **/*IT.java, and **/*ITCase.java. So you'll want to change to name of the class to MyIT or MyITCase or something like that.

http://maven.apache.org/plugins/maven-failsafe-plugin/integration-test-mojo.html#includes

sblundy
  • 60,628
  • 22
  • 121
  • 123
  • Thanks a lot for your answer. I missed that. I tried that but still I'm getting the same error. I have updated question with the latest tries.. – raksja Jan 14 '12 at 03:26
  • @techastute The stack trace only has surefire packages, no failsafe ones, so the problem is probably there. Try excluding the tests you have included in the failsafe configuration or disabling surefire entirely. – sblundy Jan 14 '12 at 04:14
2

There appears to be a bug in surefire 2.11. It does not like to function with

<useManifestOnlyJar>false</useManifestOnlyJar>

I filed a bug. http://jira.codehaus.org/browse/SUREFIRE-819

Scott Carey
  • 1,587
  • 17
  • 13