idea sbt project when I run test case it does not compile - intellij-idea

I use JUnit for the test,when I change some codes, I must make project manually, it can't auto compile like maven. If I doesn't make project it is the last time code.
Can anybody tell me why? Thanks a lot!

Actually I need change the before launch 'make' to 'sbt action',then I run or debug project it can auto compile in SBT project.

Related

How to run sbt task on make project in IntelliJ IDEA?

I'm working on a scalajs project. My workflow is: make code changes, make project in IntelliJ, go to sbt and run fastOptJS task to produce js file, go to browser and test. I would like to remove the step of manually running fastOptJS task in sbt and make that happen automatically when I make project in IDEA. Is there any way to do that?
UPD: It would be also nice to keep sbt running between fastOptJS calls, cause it takes time for sbt to start.
You can simply start the JavaScript compilation with the sbt watch mode.
Select Run | Edit configurations... and add a new SBT Task by pressing the green plus. In the field "Tasks:" define ~fastOptJS and then run the new configuration.
It will compile again whenever you have changed something.
This should be the workaround for your propose, instead of use "Make Project ( Ctrl + F9 )", you can create a run in IDEA and configure an external tool as the image shown, where you can run the fastOptJS task in sbt.

How to set up IDEA to execute post compilation task?

When trying to run some code after compilation is finished, I wrote the following in my sbt build:
compile in Compile <<= (compile in Compile) map { x=>
// post-compile work
doFoo()
x
}
Which works well if I run sbt compile from command line, but doesn't get executed when I build from IntelliJ IDEA.
Is there any way to have IntelliJ IDEA run my post compilation step?
Looks like the only way IntelliJ IDEA supports is via Ant, unfortunately.
See VS post build event command line equivalent in IntelliJ IDEA?.
Also, if you go down this route, you might be interested to use ant4sbt.
IDEA has Run/Debug configurations.
In the Before Launch option, normally we have Make as the default action.
It is a matter of simply adding a Run external Tool action after Make. We can define any number of actions.
The external tool could invoke SBT.
Or we can remove Make and call SBT to handle all the process. The only inconvenience of this, is that is a little less confortable to go to syntax errors when compiling.

how to set up an automatic compilation of test classes?

Intellij idea not compiles special classes when running test. Now I run the compilation manually via activator console. How can I customize the intellij idea to run automatically when start a compilation of test?
I'm not sure if I got you right but you can try to right click your test class and choose "Run [your_class]". It will compile the needed classes.

Running test without compile in SBT - how-to

I'm new to SBT and I would like to know if it is possible to run tests without compiling. I mean to use a set of classes that have been already compiled.
Is this possible and what should I do to get this done?
sbt detects the available tests during compilation for efficiency. To run already compiled tests that are on the classpath and not in source files, it would be necessary to explicitly list them in the definedTests task. This isn't too straightforward, though.

Intellij IDEA compiles all modules even though I asked for only 1

I have several modules in the project with a complex dependency structure. When I want to compile and run unit tests for 1 module, I want IDEA to ignore any compilation errors in unrelated modules. How can I do that? Currently IDEA compiles everything even if I say "compile module 1".
I don't want to setup several different projects for this.
In the test Run configuration specify the corresponding module. IntelliJ IDEA will compile only this module and required dependencies, it will not try to compile other modules if this test module doesn't depend on them.
If for some reason it doesn't work as expected, please try to share a small sample to illustrate the problem.
Try checking your dependencies. I had this same issue because the Ivy plug-in had added what it thought was a needed lib which contained a class that would not compile due to a missing dependency. Once I removed it, the build ran fine.