Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to ignore certain unit tests?

I'm currently working on a project which uses JUnit4 extensively throughout all the modules. We're using Maven2 to build the project and Hudson for continuous integration. The project is built and run under Java 1.5.

We've recently added quite a large raft of unit tests which are needed at times, but don't want to be run during the build process (but other unit tests in the same project do).

I want to know if there's some kind of annotation that can be applied to the tests, or some configuration that can be made to Maven that would ignore unit tests that live under a certain package or in a certain test class at build time?

There's possibly the alternative of just putting these particular tests in a normal class that would be run through main, but that's not ideal.

Thanks for your suggestions

like image 476
James Camfield Avatar asked Oct 20 '09 08:10

James Camfield


1 Answers

You can configure maven-surefire-plugin.

For example:

<project>
<build>
<plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.4.2</version>
    <configuration>
      <excludes>
        <exclude>**/TestCircle.java</exclude>
        <exclude>**/TestSquare.java</exclude>
      </excludes>
    </configuration>
  </plugin>
</plugins>

EDIT:
Another solution is to define profiles in which all test will be run e.g. by hudson. In development mode you can use subset of all test to speed up development (or all test might be in default profile, choosen test in dev profile - so you need run maven with -PprofileName attribute). This example better suits for integration tests that take loger to run.

like image 105
cetnar Avatar answered Sep 22 '22 09:09

cetnar