philburns
philburns

Reputation: 330

IntelliJ does not use JUnit import in Integration Tests (Gradle project)

I have a predefined project structure with a working Gradle dependency management and the following Gradle JUnit resolving:

dependencies {
    [...]
    testCompile "junit:junit:${versions.junit}"
    integrationTestCompile "junit:junit:${versions.junit}"
}

The project structure is

<project>
    <module>
        src
            integration-test
            main
            test

Now, while the test classes compile well in IntelliJ, the integrationTest classes still don't. On ...

import org.junit.Assert;

... I am told: "Cannot resolve symbol 'Assert'.

As an IntelliJ (and also Gradle) newbie, I am quite confused about handling this problem. While this answer tells me that I could map both, testCompile and integrationTestCompile to IDEA's test scope (without describing how), that answer refers to the Gradle IdeaModule documentation, but that is not very explanatory at all at this point.

So, what is the right or best approach and what exactly has to be done?

Upvotes: 2

Views: 680

Answers (1)

philburns
philburns

Reputation: 330

The problem was meanwhile solved by:

A) In build.gradle type:

configurations {
    provided
    testCompile.extendsFrom provided
    integrationTestCompile.extendsFrom testCompile
    integrationTestRuntime.extendsFrom testRuntime
    [...]
}

B) Gradle Refresh

Upvotes: 1

Related Questions