4

There are sereral test some of them are too slow. Can maven be configured to skip/fail test when it is running say ore then 2000 milliseconds?

Cherry
  • 31,309
  • 66
  • 224
  • 364

2 Answers2

0

As pointed out by @KrishnanunniPV the forkedProcessTimeoutInSeconds can help you solve this issue. If you don't mind failed tests you would just need to add in your pom, in the build section:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.19.1</version>
    <configuration>
        <forkedProcessTimeoutInSeconds>2</forkedProcessTimeoutInSeconds>
    </configuration>
</plugin>

If you want your build to succeed even though the timeout has passed, you can just do:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.19.1</version>
    <configuration>
        <forkedProcessTimeoutInSeconds>2</forkedProcessTimeoutInSeconds>
        <testFailureIgnore>true</testFailureIgnore>
    </configuration>
</plugin>
Adonis
  • 4,670
  • 3
  • 37
  • 57
0

I think it is better for example to say that tests that takes too long are integration tests(for example suffix them as IT) and then say to maven to run them just when your maven integration test profile is enabled.

Spasoje Petronijević
  • 1,476
  • 3
  • 13
  • 27
  • You have a good point, I would just add some example(s) to improve the understanding for everyone – Adonis Mar 22 '17 at 13:21