Java – can some unit tests be ignored?

I am developing a project that uses JUnit 4 widely in all modules We are using Maven 2 to build the project, and Hudson can continue to integrate The project is built and run according to Java 1.5

We have recently added a large number of unit tests that are sometimes needed but do not want to run during the build process (but other unit tests in the same project)

I want to know whether there are some comments that can be applied to tests, or whether Maven can be configured. These configurations may ignore the unit tests generated in a package or a test class,

It is possible to just put these specific tests in an ordinary class, which can be run through main, but this is not ideal

Thank you for your advice

Solution

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 where all tests will run In Hudson's development mode, you can use a subset of all tests to speed up development (or all tests may be in the default configuration file, and you can choose to test in the configuration file), so you need to run Maven. Com with the - pprofilename attribute This example is more suitable for the integration test of running logger

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>