Giter Club home page Giter Club logo

Comments (2)

tkrullmann avatar tkrullmann commented on August 11, 2024

Hi,
if I understand you correctly you have an integrationTest testset in C which contains some tests in addition to shared test utils that you would like to reuse in other modules.

First, I would strongly suggest to move the shared code to a separate "test library" that contains no test but only utilities. Otherwise, with the default settings of JUnit or TestNG, you would run those tests in every project that imports the library.

This scenario isn't something that the plugin covers directly. In general (without the plugin) you would follow these steps:

  1. In project C:
    a) Create a source set for the test library (e.g. testLib)
    b) Create a Jar task that packages the test library (e.g. testLibJar)
    c) Create a configuration under which you will publish it (e.g. testLib)
    d) Declare an artifact that connects the configuration with the JAR
    e) optionally, if in project C you also have tests that depend on the testLib, use the testsets plugin and declare a dependency like this
    integrationTestImplementation sourceSets.testLib.output

Now, I suppose you could probably use the test sets plugin to achieve part of this because it covers (a) and (b) and (d) for you, by making a testSet that doesn't actually contain any tests. However you would still need to do (c) yourself.

  1. In projects A and B:
    a) use the test sets plugin
    b) Declare a dependency like
    integrationTestImplementation project(path: ':C', configuration: 'testLib')

So something like this (just jotting down, not tested code ;-) )

In project C

// 1a
sourceSets { testLib }

// 1b
task testLibJar(type: Jar) {
    from sourceSets.testLib.output
}

// 1c
configurations { testLib }

// 1d
artifacts {
    testLib testLibJar
}

// 1e
dependencies {
    integrationTestImplementation sourceSets.testLib.output
}

When "abusing" the plugin:

// 1c
configurations { testLib }

// 1a, 1b and 1d
testSets {
    testLib {
        publishArtifact = true
        artifactConfigurationName = 'testLib'
    }
}

It could definitely be easier, but this is not really the scenario the plugin tries to address. I've been thinking about how to allow something like test libraries in the plugin, but so far there is no direct support.
Hope that helps!

from gradle-testsets-plugin.

kowlown avatar kowlown commented on August 11, 2024

Hi thank you for your answer.
My project C contains only shared test utils, no tests.

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.