简体   繁体   中英

Why does Intellij unit test view show a much shorter run time than actual wall clock time of running tests?

The Intellij Run view shows the runtime of each individual test. I've a module with about 800 tests for which Intellij indicates about 1s500ms. However, the tests clearly take significantly longer to run as measure by wall clock time.

These are pure unit tests, no external system (or file system) connections, so they are 100% CPU bound (barring operating system paging, etc but I've a ton of memory so that's not an issue).

  1. What are the sources of the discrepancy? Does Intellij not take into account setup/teardown and other bootstrapping?
  2. Any way to make it show the wall clock time it took to run all tests?
  3. Any ideas how I can speed the tests up (eg can I make them run in parallel?)

Thank you.

The test runner only counts the setup and run time of the test. There is usually additional time spent for the build. Even if the project and tests have been built already, the build system first needs to figure out if there were any changes. Depending on your build system and the size of your project, this might take significant time. gradle is notorious for this. In Eclipse (back in the day, when I was still using it) this used to be much better, because it builds Java code very efficiently in the background. Modern build systems suffer from these additional delays, because they do not only compile and package, but they also check external dependencies.

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