Project configuration plugin
As a user I would like to be able to use a Gradle plugin to configure projects.
Total Runs | Success Rate | Failures | Errors | Skipped | Total time (ms) |
---|---|---|---|---|---|
7 | 100.0% | 0 | 0 | 0 | 1 minutes, 12.774 seconds |
TestSubject:
Issues:
Features
- should not throw an exception
- should configure IDEA plugin
- should configure Checkstyle plugin
- should configure PMD plugin
- should configure JaCoCo plugin
- should build project with plugin enabled
- should fail build project with plugin enabled and code containing duplications
should not throw an exception
Result: PASS Time: 2.740 seconds
- Given a simple project path
def path = getClass().getResource('/simple-project')
- And a gradle project
def project = ProjectBuilder.builder().withProjectDir(Paths.get(path.toURI()).toFile()).build()
- When the unit under test is applied as a plugin
project.plugins.apply('io.github.gregoranders.project-configuration')
- Then no exceptions should be thrown
noExceptionThrown()
should configure IDEA plugin
Result: PASS Time: 2.315 seconds
- Given a simple project path
def path = getClass().getResource('/simple-project')
- And a gradle project
def project = ProjectBuilder.builder().withProjectDir(Paths.get(path.toURI()).toFile()).build()
- And a set of required plugins
project.plugins.apply('java')
project.plugins.apply('idea')
- When the unit under test is applied as a plugin
project.properties.ext['description'] = 'description'
project.properties.ext['author'] = 'author'
project.properties.ext['email'] = 'email'
project.version = 'version'
project.java.sourceCompatibility = JavaVersion.VERSION_1_8
project.java.targetCompatibility = JavaVersion.VERSION_1_8
project.plugins.apply('io.github.gregoranders.project-configuration')
- Then the IDEA plugin configuration was applied
project.extensions.idea.module.downloadJavadoc
project.extensions.idea.module.downloadSources
project.rootProject.idea.project.vcs == 'Git'
project.rootProject.idea.project.jdkName == 'jdk-1.8'
project.rootProject.idea.project.languageLevel == new IdeaLanguageLevel('1.8')
- And no exceptions are thrown
noExceptionThrown()
should configure Checkstyle plugin
Result: PASS Time: 0.300 seconds
- Given a simple project path
def path = getClass().getResource('/simple-project')
- And a gradle project
def project = ProjectBuilder.builder().withProjectDir(Paths.get(path.toURI()).toFile()).build()
- And a set of required plugins
project.plugins.apply('java')
project.plugins.apply('checkstyle')
- When the unit under test is applied as a plugin
project.properties.ext['description'] = 'description'
project.properties.ext['author'] = 'author'
project.properties.ext['email'] = 'email'
project.properties.ext['checkstyleVersion'] = '1.0.0'
project.plugins.apply('io.github.gregoranders.project-configuration')
- Then the Checkstyle plugin configuration was applied
project.extensions.checkstyle.toolVersion == '1.0.0'
!project.extensions.checkstyle.ignoreFailures
- And no exceptions are thrown
noExceptionThrown()
should configure PMD plugin
Result: PASS Time: 0.165 seconds
- Given a simple project path
def path = getClass().getResource('/simple-project')
- And a gradle project
def project = ProjectBuilder.builder().withProjectDir(Paths.get(path.toURI()).toFile()).build()
- And a set of required plugins
project.plugins.apply('java')
project.plugins.apply('pmd')
- When the unit under test is applied as a plugin
project.properties.ext['description'] = 'description'
project.properties.ext['author'] = 'author'
project.properties.ext['email'] = 'email'
project.properties.ext['pmdVersion'] = '1.0.0'
project.plugins.apply('io.github.gregoranders.project-configuration')
- Then the PMD plugin configuration was applied
project.extensions.pmd.toolVersion == '1.0.0'
project.extensions.pmd.consoleOutput
project.extensions.pmd.incrementalAnalysis
!project.extensions.pmd.ignoreFailures
project.extensions.pmd.ruleSetConfig != ''
project.tasks.cpdMain != null
- And no exceptions are thrown
noExceptionThrown()
should configure JaCoCo plugin
Result: PASS Time: 0.254 seconds
- Given a simple project path
def path = getClass().getResource('/simple-project')
- And a gradle project
def project = ProjectBuilder.builder().withProjectDir(Paths.get(path.toURI()).toFile()).build()
- And a set of required plugins
project.plugins.apply('java')
project.plugins.apply('jacoco')
- When the unit under test is applied as a plugin
project.properties.ext['description'] = 'description'
project.properties.ext['author'] = 'author'
project.properties.ext['email'] = 'email'
project.properties.ext['jacocoVersion'] = '1.0.0'
project.plugins.apply('io.github.gregoranders.project-configuration')
- Then the JaCoCo plugin configuration was applied
project.extensions.jacoco.toolVersion == '1.0.0'
- And no exceptions are thrown
noExceptionThrown()
should build project with plugin enabled
Result: PASS Time: 57.784 seconds
- Given a simple project path
def path = getClass().getResource('/simple-project')
- When the project is build
def result = GradleRunner.create()
.withProjectDir(Paths.get(path.toURI()).toFile())
.withPluginClasspath()
.withEnvironment([
'CI' : 'true',
'GPG_KEY_ID' : '0xfsahgdf237643257',
'GPG_KEY' : 'test',
'GPG_PASSPHRASE': 'test',
])
.withArguments(getGradleJVMArgs(), 'clean', 'check', 'build')
.build()
- Then the build result contains :checkstyleMain
result.output.contains(':checkstyleMain')
- And the build result contains :checkstyleTest SKIPPED
result.output.contains(':checkstyleTest SKIPPED')
- And it contains :pmdMain
result.output.contains(':pmdMain')
- And it contains :pmdTest SKIPPED
result.output.contains(':pmdTest SKIPPED')
- And it contains :cpdMain
result.output.contains(':cpdMain')
- And it contains :spotbugsMain
result.output.contains('spotbugsMain')
- And it contains :spotbugsTest SKIPPED
result.output.contains('spotbugsTest SKIPPED')
- And it contains :jacocoTestReport
result.output.contains(':jacocoTestReport')
- And it contains :jacocoTestCoverageVerification
result.output.contains(':jacocoTestCoverageVerification')
- And it contains :dependencyCheckAnalyze
result.output.contains(':dependencyCheckAnalyze')
- And it contains :sourcesJar
result.output.contains(':sourcesJar')
- And no exceptions are thrown
noExceptionThrown()
should fail build project with plugin enabled and code containing duplications
Result: PASS Time: 9.138 seconds
- Given a simple project path
def path = getClass().getResource('/simple-project-with-duplications')
- When the project is build
GradleRunner.create()
.withProjectDir(Paths.get(path.toURI()).toFile())
.withPluginClasspath()
.withArguments(getGradleJVMArgs(), 'clean', 'check')
.build()
- Then a exception is thrown
UnexpectedBuildFailure exception = thrown()
- And it contains the expected message
exception.getMessage().contains('Copy/Paste analysis found 6')