Running Unit Tests seems not possible in IntelliJ


I started using CUBA Studio v6.10.1 with Plattform v6.10.5 on Windows 7.
IntelliJ Ultimate 2018.3.1 is installed as IDE.

I created an application inside the studio, also added a service and now I wanted to test the service. So I wrote another Unit test inside the core module.

And at that point I found a problem that I cannot solve on my own:
IntelliJ can mark a directory to contain either sources or resources. When I open the IDE from CUBA Studio, the directories are just marked to contain resources. So the java files get copied and not compiled. In IntelliJ, you divide stuff up e.g. src/main/java for sources and src/main/resources for the resources. But CUBA placed everything into one directory (e.g. modules/global/src/ contains xml resources and also a subdirectory entity with java code.)

What went wrong? How to fix it so that I can run the unit tests?

Thank you in advance for your help / pointing me to the correct direction.

Kind regards,



We are using Intellij for tests and do not have any problems there. CUBA uses standard Intellij modules layout:

module / 
   src / 
   test /

If you generate an empty project, you will see that Studio generates demo test classes in modules/core/test/ directory. Just put your new test there and you will be able to run it using standard Intellij Debug configuration.


If you open this SampleIntegrationTest you will see standard run buttons on the gutter:


Just click on those buttons to run test.


The same applies to other modules, just create test folder in module if needed.

1 Like

Hi Yuriy,

thank you for your reply. From your screens, I see that the source directories are just marked as sources / test sources and I was able to compile everything from inside IntelliJ.

Starting the tests failed with an error that the command line was to long which IntelliJ suggested to solve with 3 possible options (I decided to use a file for the classpath).

But then I ended up with the problem that a component was unable to load a dependency. A component of my solution is using the IMAP addon and I wrote a component, which has a @Inject ImapAPI imapAPI; before a function which handles a NewEmailImapEvent. At this point I thought that it misses some configuration because a config file wasn’t copied to a directory where it is required…

I also searched on this problem and I found, that inside unit tests, instead of Inject I should use AppBeans.get() calls. But the Inject was inside a component and not inside the unit test. I will test if that solves my issues later.

With kind regards,


Please note, that all required addons must be declared in your TestContainer:

public class DemoTestContainer extends TestContainer {

    public DemoTestContainer() {
        appComponents = new ArrayList<>(Arrays.asList(
                // add CUBA premium add-ons here
                // and custom app components if any
1 Like

Great, that is at least one of my errors. I will give it a try this evening and will give you feedback about my results.

Hi Yuiy,

thank you very much for your assistance! The unit tests are now working without any further problems!

With kind regards,