(some) JUnit test execution super slow
已回答
Yes, I have seen https://intellij-support.jetbrains.com/hc/en-us/community/posts/206257979-JUnit-execution-abysmally-slow , but that post is 8 years old, and doesn't give any hints what to do.
So: I am using the (always) latest version of IntelliJ community on MacOs.
We have a large project, with many test cases. Typically, a test class passes in 1, 2 seconds.
But for me, since a few weeks, sometimes, a single test method needs 5+ seconds. So I easily look at 30 to 60 seconds for a single test class to finish.
The problem: other people, running the same test, with same IntelliJ on their local machines: < 1 second.
Any idea how I could approach this, to figure why my tests run so slow?
请先登录再写评论。
Do you use Platform test runner? Do you use Maven/Gradle in project? Are there any background progress indicators shown when tests are launched?
There could be a proxy issue or slow dns resolve for the localhost, similar to https://stackoverflow.com/a/39698914/2000323 Check the solution mentioned in SO post. Try also deactivating all network interfaces and check.
Try also using different JDK/Junit version.
Most of the time, I use
No maven/gradle in our project.
Update:
So: the given recommendations did not help, but strangely enough, switching the JDK to a different one and back did the job.
Update: I am back to 6 seconds per test method ... and this time, switching the JDK doesn't help.
Try with antivirus/firewall disabled or make sure that IDE settings/caches directories IDE installation home and project files are excluded from the scan.
Make sure you have correct network routing/dns settings including properly configured loopback (localhost) address.
No antivirus running on my machine. Beyond that, my overall setup didn't change, same machine, same connections, same everything when it worked as expected, and now, when it runs slower.
Even more interestingly, some tests complete normally in ms, some take seconds.
What part takes time most? Process startup, the running tests itself?
You can profile the process by taking it's thread dumps with jstack: https://intellij-support.jetbrains.com/hc/en-us/articles/206544899