Giter Club home page Giter Club logo

Comments (8)

tkrullmann avatar tkrullmann commented on August 11, 2024

Hi,
I've got your sample project to compile and run the test with two small modifications:

  • make sure that the groovy-all dependency version matches the one used by Spock, i.e. either upgrade groovy-all to 2.4.x or downgrade Spock to 1.1-groovy-2.3
  • remove the idea plugin (not sure why this fixes the problem, but I'll look into it). The idea plugin built into Gradle was used by early versions of the IDEA Gradle support, right now I think it's only used to generate IDEA project files initially, IDEA now seems to use a different mechanism under the hood (which is neither documented nor open-sourced). That's why unfortunately the possibilities for a plugin to influence IDEA's behavior are now very limited.

from gradle-testsets-plugin.

MartinAhrer avatar MartinAhrer commented on August 11, 2024

Agree, removing the idea plugin makes the project work. However, I think the idea plugin still has relevance. It allows to customise the workspace (e.g. by manipulating the XML based configuration of IDEA projects).
For example in my project where I originally hit the problem I'm also using the https://github.com/tbroyer/gradle-apt-plugin. See https://github.com/SoftwareCraftsmen/continuousdelivery/blob/master/build.gradle

It has a plugin for managing apt configuration in IDEA. As soon as I add the plugin (id "net.ltgt.apt-idea" version "0.19"), the same symptom appears (as the apt plugin pulls in the idea plugin again).

from gradle-testsets-plugin.

dje1990 avatar dje1990 commented on August 11, 2024

Suggestion doesn't work, ignore.

Hi MartinAhrer tkrullmann

At a guess, could you use something similar to the below? (untested)

sourceSets {
integrationTest {
compileClasspath += sourceSets.sharedTest.runtimeClasspath
}
}

from gradle-testsets-plugin.

MartinAhrer avatar MartinAhrer commented on August 11, 2024

After investigating a bit further: Could it be that this is a bug in IDEA? IDEA is able to run the code referencing the shared test code from the integration test. But the editor is showing the referenced class from sharedTest as unavailable (red in my color-scheme).

I have also tried replacing my setup by your concept of TestLibrary.

testSets {
sharedTest(TestLibrary)
integrationTest { imports sharedTest }
}

The effect is the same!

from gradle-testsets-plugin.

tkrullmann avatar tkrullmann commented on August 11, 2024

Strange, I'm experiencing the same.

I also noticed that the problem goes away when I mark testCommon/java as "sources root" instead of "test sources root".

So maybe the IDEA editor has a problem with one test source importing another (even though the runner seems to take it).

The only "fix" I can imagine is to exempt test libraries from being marked as "test sources" by the plugin.

from gradle-testsets-plugin.

MartinAhrer avatar MartinAhrer commented on August 11, 2024

I have upgraded to 2.1.1 (with Gradle 5.1.1) and added a test library and trying to use it with a out-of-the-box source set test provided by the java/groovy plugin.

testSets {
    createLibrary ('sharedTest')
    unitTest { imports sharedTest }
    integrationTest { imports sharedTest }
}

The IDE is showing the same symptom but also now the build fails the compileTestGroovy task when running ./gradlew test.

This is the commit showing the bug: MartinAhrer/gradle-testset-plugin-ideabug@cb5f1ad

from gradle-testsets-plugin.

gokhanoner avatar gokhanoner commented on August 11, 2024

Using 2.1.1 with Gradle 5.5.1

trying to add a dependency from a module to integration tests:

dependencies {
    implementation project(":core")
    implementation project(":xxx")
    
    e2eTestImplementation project(":xx").sourceSets.test.output
}

testSets {
    e2eTest
}

This also fails with

Could not find method e2eTestImplementation() for arguments [test classes] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

Both IDEA & CLI compile fails with the same error

If I remove the testSet definition & try same with like below, it works:

testImplementation project(":xx").sourceSets.test.output

from gradle-testsets-plugin.

MartinAhrer avatar MartinAhrer commented on August 11, 2024

After upgrading to version 2.2.1 of the plugin and Gradle 6.0.1 this issues still exists (with current IDEA 2019.1.3).
But a workaround is to use the new testFixtures feature introduced with Gradle 5.6.x. The IDE will then properly recognise the classes from the fixture.

testSets {
    integrationTest {
    }
}
sourceSets {
    testFixtures {
        java {
            srcDirs = ['src/sharedTest/java']
        }
        groovy {
            srcDirs = ['src/sharedTest/groovy']
        }
    }
}

from gradle-testsets-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.