Compile just what's needed and ignore compile errors elsewhere

Answered

I frequently write unit tests as I'm developing to test bits of code I'm writing.

I'm finding it very tedious that in order to run the unit test I need to recompile EVERYTHING.  Is there a way to make it compile only what is needed.

I usually include the source code from other projects to make debugging easier, but this usually stops me from running any unit tests as I can't compile unless I go to the effort of adding the dependancies for all projects I've included.

So at the moment if I want to write and run unit tests the first thing I have to do is remove a whole bunch of src directories from my project so I can actually compile and run the tests.

I'm sure I'm missing something, there has to be an easier way.

Cheers,
Pete

6 comments
Comment actions Permalink

Hello ProggerPete,

The compilation in IDEA works per module. In a run configuration, you specify
the "Use classpath and JDK of module" option, and before running the tests
IDEA compiles the specified module and all its dependencies.

If you include source code of other projects as separate modules and don't
add any dependencies from your module with unit tests to those modules, they
won't be compiled when you run the tests.

I frequently write unit tests as I'm developing to test bits of code
I'm writing.

I'm finding it very tedious that in order to run the unit test I need
to recompile EVERYTHING. Is there a way to make it compile only what
is needed.

I usually include the source code from other projects to make
debugging easier, but this usually stops me from running any unit
tests as I can't compile unless I go to the effort of adding the
dependancies for all projects I've included.

So at the moment if I want to write and run unit tests the first thing
I have to do is remove a whole bunch of src directories from my
project so I can actually compile and run the tests.

I'm sure I'm missing something, there has to be an easier way.

Cheers,
Pete
---
Original message URL:
http://www.jetbrains.net/devnet/message/5232638#5232638

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink

I'm with Pete on this one. I work on a project that consists of several modules, many of which depend several others. I'd like to see IDEA compile just what is needed as very often I write a simple test case that only depends on a class that doesn't depend on other stuff. Yet, this class is part of a module that depends on other modules, which in turns triggers compilation of lots of code when only two classes really needed to be compiled...

1
Comment actions Permalink

Yes, very annoying. I am writing a simple unit test which I cant check whether it is working because of some other classes that my test does not uses and is failing compiling.

0
Comment actions Permalink

You can exclude the code that doesn't compile from the compilation.

1
Comment actions Permalink

Can you show us how to do please?

0
Comment actions Permalink

File | Settings | Build, Execution, Deployment | Compiler | Excludes:

0

Please sign in to leave a comment.