Skip to Content
author's profile photo Former Member
Former Member

Running unit tests in Intellij Idea

I'm having difficulties running unit tests inside Idea. Trying to run the class as a junit test first fires build, and for some reason the build starts to build everything, including generating beans to models.jar (even if the whole project is already built with ant all). The beans get generated somehow horribly wrong missing most of the properties and the project won't compile. I get errors like:

 Error:(43, 29) java: cannot find symbol
   symbol:   method setConfiguratorType(de.hybris.platform.catalog.enums.ConfiguratorType)
   location: variable item of type de.hybris.platform.commercefacades.order.data.ConfigurationInfoData

When I look at the beans they only seem to include properties from sapproductconfigfacades, everything else is missing.

If I try to run the test without the build step the test class is not found.

I've imported the project to Idea with Hybris plugin. I'm using Hybris 6.4.0.2

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • Best Answer
    Posted on Jan 10, 2018 at 11:45 PM

    Hi, to achieve a correct compilation and unit tests you need to do the following.

    • Prior importing the project, make sure it's compiled by ant (any clean all).

    • Import the project with the current version of the plugin. The project refresh is designed to work within the plugin version you have. I you upgrade to newer plugin version it is likely that some settings is missing.

    • Current plugin version is 8.2 and required IDEA 2017.3

    • Once imported you need to decide if you want to continue using ant OR native build. You can't mix and match.

    • Ok, you decided for native build because it is much faster as native build will compile only changed classes. For the first time all classes are "dirty" and IDEA will compile everything. After the initial import you need to compile the project with IDEA native builder. alt text

    You have now two option for integration tests. - Execute the test locally. For integration test it means starting up hybris platform which can take some time. - Execute test on a remote hybris instance. Ideal for integration tests alt text


    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 10, 2018 at 10:25 PM

    Hi.

    Trying to run the class as a junit test first fires build, and for some reason the build starts to build everything, including generating beans to models.jar (even if the whole project is already built with ant all

    Ant build and "native" build in Intellij IDEA are two independent systems. You can not expect IDEA to understand that the project is already build because you've run "ant clean all". I recommend you to rebuild your project from Intellij using "Build->Rebuild Project" before running your tests. Once you compile it at least once, IDEA will remember that and the next time it will compile only changed files.

    The beans get generated somehow horribly wrong missing most of the properties and the project won't compile.

    If you can please provide details about your project setup, how you structure and import the project. Because it is not clear what exactly is happening.

    And for the rest of the people having problems: please create a support ticket in our support project in JIRA and we will work with you to resolve your problems.

    Thank you.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 09, 2017 at 12:19 PM
    -1

    Found a workaround for this: Hybris Integration plugin needs to be turned off from Idea's plugin settings when running JUnit tests. Somehow it seems to mess up the build.

    Add a comment
    10|10000 characters needed characters exceeded