Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent IntelliJ from compiling src-Classes when Unit-Testing

I have the following Project Structure

/
   src/  # src-files for the app
    org.mayapp.main.Main/
 test/ # unit-tests
    org.myapp.test.main.MainTestSuite/

When I want to run my Unit-Tests, e.g. org.myapp.test.main.MainTestSuite, IntelliJ always tries to compile all the packages in the whole project.

I want to prevent this, because I am currently developing on a part of my app and still want to run the Unit-Tests on other parts of the app.

Is there a way to prevent IntelliJ from compiling the whole project before running the Unit-Tests?

like image 357
F.P Avatar asked Nov 25 '25 06:11

F.P


1 Answers

When you run a test in IntelliJ you'll see it adds a run target for that test, see Run -> Edit Configurations under the JUnit section.

If you look at the run target for the test you'll see there's a Before Launch section that by default has Make selected. If you unselect Make IntelliJ won't make/compile before the test is run.

Remember to save the run target as IntelliJ creates new ones as you run different tests.

like image 81
Nick Holt Avatar answered Nov 27 '25 18:11

Nick Holt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!