Gradle utilities
As a user I would like to be able to collect dependencies of a Gradle JVM project.
Total Runs | Success Rate | Failures | Errors | Skipped | Total time (ms) |
---|---|---|---|---|---|
5 | 100.0% | 0 | 0 | 0 | 3.066 seconds |
TestSubject:
Issues:
See:
Features
- should return an empty set of dependencies of a simple project with no dependencies
- should return a set of dependencies of a simple project with dependencies
- should return a multi project with no dependencies
- should return a multi project with dependencies
- should throw an exception
should return an empty set of dependencies of a simple project with no dependencies
Result: PASS Time: 2.020 seconds
- Given a path to a simple project with no dependencies
def path = getProjectPath('simple-no-dependencies')
- When the test subject invokes getDependencies with this path
def project = testSubject.getDependencies(path)
- Then the group of the project should be “io.github.gregoranders”
project.group() == 'io.github.gregoranders'
- And the name of the project should be “simple-no-dependencies”
project.name() == 'simple-no-dependencies'
- And the version of the project should be “0.0.1”
project.version() == '0.0.1'
- And the description of the project should be “Simple project no dependencies”
project.description() == 'Simple project no dependencies'
- And the project should have no dependencies in all configurations
project.configurations().forEach(configuration -> {
assert configuration.dependencies().size() == 0
})
- And no exceptions are thrown
noExceptionThrown()
should return a set of dependencies of a simple project with dependencies
Result: PASS Time: 0.321 seconds
- Given a path to a simple project with no dependencies
def path = getProjectPath('simple-with-dependencies')
- When the test subject invokes getDependencies with this path
def project = testSubject.getDependencies(path)
- Then the group of the project should be “io.github.gregoranders”
project.group() == 'io.github.gregoranders'
- And the name of the project should be “simple-no-dependencies”
project.name() == 'simple-with-dependencies'
- And the version of the project should be “0.0.2”
project.version() == '0.0.2'
- And the description of the project should be “Simple project no dependencies”
project.description() == 'Simple project with dependencies'
- And the project should have 1 dependency in the implementation configurations
project.configurations().forEach(configuration -> {
if (configuration.name() == 'implementation') {
assert configuration.dependencies().size() == 1
assertDependency(configuration.dependencies()[0], 'org.slf4j', 'slf4j-api', '1.7.32')
}
})
- And the project should have 2 dependencies in the runtimeOnly configurations
project.configurations().forEach(configuration -> {
if (configuration.name() == 'runtimeOnly') {
assert configuration.dependencies().size() == 2
assertDependency(configuration.dependencies()[0], 'ch.qos.logback', 'logback-core', '1.2.9')
assertDependency(configuration.dependencies()[1], 'ch.qos.logback', 'logback-classic', '1.2.9')
}
})
- And no exceptions are thrown
noExceptionThrown()
should return a multi project with no dependencies
Result: PASS Time: 0.302 seconds
- Given a path to a multi project with no dependencies
def path = getProjectPath('multi-no-dependencies')
- When the test subject invokes getDependencies with this path
def project = testSubject.getDependencies(path)
- Then the group of the project should be “io.github.gregoranders”
project.group() == 'io.github.gregoranders'
- And the name of the project should be “multi-no-dependencies”
project.name() == 'multi-no-dependencies'
- And the version of the project should be “0.0.1”
project.version() == '0.0.1'
- And the description of the project should be “Multi project no dependencies”
project.description() == 'Multi project no dependencies'
- And the project should have no dependencies in all configurations
project.configurations().forEach(configuration -> {
assert configuration.dependencies().size() == 0
})
- And the project should have 3 sub projects
project.subProjects().size() == 3
- And the first sub project should be named “api”
project.subProjects()[0].name() == 'api'
- And the group of it should be “io.github.gregoranders”
project.subProjects()[0].group() == 'io.github.gregoranders'
- And the second sub project should be named “impl”
project.subProjects()[1].name() == 'impl'
- And the group of it should be “io.github.gregoranders”
project.subProjects()[1].group() == 'io.github.gregoranders'
- And the third sub project should be named “test”
project.subProjects()[2].name() == 'test'
- And the group of it should be “io.github.gregoranders”
project.subProjects()[2].group() == 'io.github.gregoranders'
- And no exceptions are thrown
noExceptionThrown()
should return a multi project with dependencies
Result: PASS Time: 0.254 seconds
- Given a path to a multi project with dependencies
def path = getProjectPath('multi-with-dependencies')
- When the test subject invokes getDependencies with this path
def project = testSubject.getDependencies(path)
- Then the name of the project should be “multi-with-dependencies”
project.name() == 'multi-with-dependencies'
- And the version of the project should be “0.0.1”
project.version() == '0.0.1'
- And the description of the project should be “Multi project with dependencies”
project.description() == 'Multi project with dependencies'
- And the project should have no dependencies in all configurations
project.configurations().forEach(configuration -> {
assert configuration.dependencies().size() == 0
})
- And the project should have 3 sub projects
project.subProjects().size() == 3
- And the first sub project should be named “api”
project.subProjects()[0].name() == 'api'
- And it should have the version “0.0.2”
project.subProjects()[0].version() == '0.0.2'
- And it should have no dependencies in all configurations
project.subProjects()[0].configurations().forEach(configuration -> {
assert configuration.dependencies().size() == 0
})
- And the second sub project should be named “impl”
project.subProjects()[1].name() == 'impl'
- And it should have the version “0.0.2”
project.subProjects()[1].version() == '0.0.3'
- And it should have 2 dependencies in the implementation configuration
project.subProjects()[1].configurations().forEach(configuration -> {
if (configuration.name() == 'implementation') {
assert configuration.dependencies().size() == 2
assertDependency(configuration.dependencies()[0], 'io.github.gregoranders', 'api', '0.0.2')
assertDependency(configuration.dependencies()[1], 'org.slf4j', 'slf4j-api', '1.7.32')
}
})
- And the third sub project should be named “test”
project.subProjects()[2].name() == 'test'
- And it should have the version “0.0.4”
project.subProjects()[2].version() == '0.0.4'
- And it should have 2 dependencies in the implementation configuration
project.subProjects()[2].configurations().forEach(configuration -> {
if (configuration.name() == 'implementation') {
assert configuration.dependencies().size() == 2
assertDependency(configuration.dependencies()[0], 'io.github.gregoranders', 'impl', '0.0.3')
assertDependency(configuration.dependencies()[1], 'org.slf4j', 'slf4j-api', '1.7.32')
}
})
- And it should have 1 dependencies in the testImplementation configuration
project.subProjects()[2].configurations().forEach(configuration -> {
if (configuration.name() == 'testImplementation') {
assert configuration.dependencies().size() == 1
assertDependency(configuration.dependencies()[0], 'org.junit.jupiter', 'junit-jupiter-engine', '5.8.2')
}
})
- And no exceptions are thrown
noExceptionThrown()
should throw an exception
Result: PASS Time: 0.077 seconds
- Given an invalid path
def path = Path.of('foo')
- When the test subject invokes getDependencies with this path
testSubject.getDependencies(path)
- Then an exception is thrown
GradleUtilitiesException exception = thrown()
- And the message of the exception matches
exception.getMessage().contains("Could not fetch model of type 'Project' using connection to Gradle distribution")
- And the cause is of type “BuildException”
exception.getCause() instanceof BuildException