简体   繁体   中英

How to speed up JUnit Tests in Netbeans

In an ant based java project in Netbeans, unit tests take for ever to complete. How do I spead up the unit tests. Eclipse runs the same tests quite fast and same is the case on the command-line.

在此处输入图片说明

  • Open the netbeans options window.
  • Go to Java -> Ant tab.
  • Add a new property junit.forkmode=once .

Apply and rerun the tests, you'll notice the tests run significantly faster. For more detail about for attribute please read.

Running junit from ant beware the fork attribute

This may cause Permgen space problem. To fix that add a vm argument in the project properties dialog box.

-Xms128m -Xmx1536m -XX:MaxPermSize=512m

在此处输入图片说明

How significant is the improvement ?

Here are the results for a project with 11,751 unit tests.

Test run without the junit.forkmode

BUILD SUCCESSFUL
Total time: 40 minutes 17 seconds

Test run with junit.forkmode=once

BUILD SUCCESSFUL
Total time: 4 minutes 31 seconds

Not specific to ant, rather than a general suggestion:

  • Use SSD
  • Download the latest Netbeans
  • Remove all the plugins you don't need
  • Use the latest version of Java
  • Specifically for every project - remove unused jars (worth reviewing your target dependency tree from time to time)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM