Building tests in Intellij for Play Framework are very slow

Is there a way to speed up the unit test build time for the Play Framework in Intellij? I am doing TDD. Whenever I run a test, it takes about 30-60 seconds to compile. Even a simple Hello World test takes time. Repeating the same test again, even without any changes, will still start the make process.

I'm on Intellij 14.1, on Play 2.3.8, written in Scala.

I already tried installing the java compiler for the eclipse, and also tried installing the Scala compiler in SBT.

+6
source share
3 answers

I assume that you know that the problem is the build time - that the actual runtime for the tests themselves is negligible.

What do you have for hardware? In my experience, 4 GB of RAM is not enough for Intellij Scala to work well - for this you need a large disk cache (for which the OS uses free RAM). SSD also helps. Use a performance monitor or similar for your OS to determine if the time is a disk, processor, or network. If it's a central processing unit, consider whether there might be a problem with heap size.

What is your build process? Are there any sbt plugins? How big is your project?

UPDATE

Starting a full rebuild without changes is incorrect. Is there anything in your tests that change project directories? If you run a dummy no-op test, does it do the same? Perhaps you, for example, write logs to the project tree?

In my limited experience, full Play builds under Intellij are several orders of magnitude slower than the pure Scala construct - I would suggest because of all the SBT plugins (view compiler, xScript compiler, xSS compiler, etc.) that have run. But increments are not so painful.

On OSX, read Activity Monitor for Performance Monitor.

UPDATE

See Intellij issue SCL-8235 for other people's experiences and workarounds for slow incremental Play builds. Vote for the problem to increase its priority and speed up its correction.

+2
source

In text 14.1.2, I made a workaround to:

1) Remove make from the tests ( Edit Configurations β†’ Defaults β†’ Scala Test β†’ Before launch β†’ (-) make )

2) Launch activator (or play ) using ~ test:compile (ex: activator ~test:compile ) or ( sbt ~ test:compile )

This prevents Intellij from invoking the playback compilation server each time make is called. Compilation is delegated to the external sbt / activator / play process for continuous compilation. The downside is that when you run your test just before the compilation is complete, you can get a NoClassDefinedFound exception. In addition, you will need to control the additional process. However, this setting is much faster compared to the default Intellij setting (for now). Hope this helps anyone.

+3
source

How about canceling existing tests and leaving only yours? Right-click the test directory (which should be green) and Unmark as Test Source Root .

0
source

Source: https://habr.com/ru/post/985573/


All Articles