Search code examples
mavenmaven-3junit4fitnessefitnesse-slim

Running Fitnesse Tests with maven


I created JUnit-tests for my Fitnesse testcases:

import org.junit.runner.RunWith;
import fitnesse.junit.FitNesseRunner;
@RunWith(FitNesseRunner.class)
@FitNesseRunner.Suite("mysuite")
@FitNesseRunner.FitnesseDir(".")
@FitNesseRunner.OutputDir("./target/fitnesse-results")
public class RunFitnesseTestMySuite {
}

Now I can execute this test like a normal JUnittestcase in Eclipse.

However, mavencompletly ignores this test. All my other JUnits are executed by maven but not this particular Fitnesse test.

This seems strange to me because @RunWith is a normal JUnitannotation and so I would expect maven to also run these tests.

Any ideas?


Solution

  • You probably have not configured surefire to run tests with a non-default name. Your test class does not match surefire's defaults and therefore will only be run if you configure the tests to run explicitly. From surefire documentation:

    By default, the Surefire Plugin will automatically include all test classes with the following wildcard patterns:

    • "**/Test*.java" - includes all of its subdirectories and all Java filenames that start with "Test".
    • "**/*Test.java" - includes all of its subdirectories and all Java filenames that end with "Test".
    • "**/*Tests.java" - includes all of its subdirectories and all Java filenames that end with "Tests".
    • "**/*TestCase.java" - includes all of its subdirectories and all Java filenames that end with "TestCase".

    If the test classes do not follow any of these naming conventions, then configure Surefire Plugin and specify the tests you want to include.

    In your case I expect you want to use something like:

          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.21.0</version>
            <configuration>
              <includes>
                <include>**/*Suite.java</include>
              </includes>
            </configuration>
          </plugin>