Skip to content
This repository has been archived by the owner on Apr 2, 2021. It is now read-only.

Commit

Permalink
Fix functional test infrastructure to work with Gradle 5 (#534)
Browse files Browse the repository at this point in the history
  • Loading branch information
johndevs committed Dec 18, 2018
1 parent 461a05b commit 7025dd9
Show file tree
Hide file tree
Showing 27 changed files with 63 additions and 19 deletions.
68 changes: 57 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import org.apache.tools.ant.filters.ReplaceTokens
*
**********************************************************************************************************************/
plugins {
id 'java-gradle-plugin'
id 'groovy'
id 'maven'
id 'idea'
Expand All @@ -46,6 +47,26 @@ ext {
testCategory = project.hasProperty('TEST_CATEGORY') ? getProperty('TEST_CATEGORY') : null
}


/***********************************************************************************************************************
*
* Sources
*
**********************************************************************************************************************/

sourceSets {
functionalTest {
groovy {
srcDir file('src/functionalTest/groovy')
}
resources {
srcDir file('src/functionalTest/resources')
}
compileClasspath += sourceSets.main.output + configurations.testRuntime
runtimeClasspath += output + compileClasspath
}
}

/***********************************************************************************************************************
*
* Repositories & Dependencies
Expand Down Expand Up @@ -111,7 +132,7 @@ idea {
/**
* Compiles the tests
*/
compileTestGroovy {
compileFunctionalTestGroovy {
classpath += configurations.proxyTest
}

Expand Down Expand Up @@ -195,12 +216,6 @@ groovydoc {
*
**********************************************************************************************************************/

/**
* Configure test phase only to run ordinary unit tests.
*/
test {
exclude '**/tests/**'
}

/**
* Run integration tests with a different tasks so they are only run when running check
Expand All @@ -219,6 +234,8 @@ task uncategorizedTests(type:Test, dependsOn:['test','jar']) {
exclude '**/tests/*ProxyTest*'
systemProperty 'integrationTestProjectVersion', version
maxParallelForks = Runtime.runtime.availableProcessors() > 1 ? Runtime.runtime.availableProcessors() - 1 : 1
testClassesDirs = sourceSets.functionalTest.output.classesDirs
classpath = sourceSets.functionalTest.runtimeClasspath
}

task widgetsetCompileTests(type:Test, dependsOn:['test','jar']) {
Expand All @@ -232,6 +249,8 @@ task widgetsetCompileTests(type:Test, dependsOn:['test','jar']) {
}
systemProperty 'integrationTestProjectVersion', version
maxParallelForks = Runtime.runtime.availableProcessors() > 1 ? Runtime.runtime.availableProcessors() - 1 : 1
testClassesDirs = sourceSets.functionalTest.output.classesDirs
classpath = sourceSets.functionalTest.runtimeClasspath
}

task themeCompileTests(type:Test, dependsOn:['test','jar']) {
Expand All @@ -245,6 +264,8 @@ task themeCompileTests(type:Test, dependsOn:['test','jar']) {
}
systemProperty 'integrationTestProjectVersion', version
maxParallelForks = Runtime.runtime.availableProcessors() > 1 ? Runtime.runtime.availableProcessors() - 1 : 1
testClassesDirs = sourceSets.functionalTest.output.classesDirs
classpath = sourceSets.functionalTest.runtimeClasspath
}

task fullCompileTests(type:Test, dependsOn:['test','jar']) {
Expand All @@ -257,6 +278,8 @@ task fullCompileTests(type:Test, dependsOn:['test','jar']) {
}
systemProperty 'integrationTestProjectVersion', version
maxParallelForks = Runtime.runtime.availableProcessors() > 1 ? Runtime.runtime.availableProcessors() - 1 : 1
testClassesDirs = sourceSets.functionalTest.output.classesDirs
classpath = sourceSets.functionalTest.runtimeClasspath
}

task runProjectTests(type:Test, dependsOn:['test','jar']) {
Expand All @@ -269,21 +292,35 @@ task runProjectTests(type:Test, dependsOn:['test','jar']) {
}
systemProperty 'integrationTestProjectVersion', version
maxParallelForks = Runtime.runtime.availableProcessors() > 1 ? Runtime.runtime.availableProcessors() - 1 : 1
testClassesDirs = sourceSets.functionalTest.output.classesDirs
classpath = sourceSets.functionalTest.runtimeClasspath
}

/**
* Runs proxy integration test that needs special configuration
*/
task proxyTest(type:Test, dependsOn: ['test','jar']) {
def oldClassPath = classpath
classpath = configurations.proxyTest
classpath += oldClassPath
testLogging {
exceptionFormat "full"
showStandardStreams = true
}
include '**/tests/*ProxyTest*'
systemProperty 'integrationTestProjectVersion', version
testClassesDirs = sourceSets.functionalTest.output.classesDirs
classpath += sourceSets.functionalTest.runtimeClasspath + configurations.proxyTest
}

/**
* Runs all the tests. Use this with --tests filter to run filtered tests in Idea.
*/
task allTests(type:Test, dependsOn:['test','jar']) {
testLogging {
exceptionFormat "full"
showStandardStreams = true
}
systemProperty 'integrationTestProjectVersion', version
testClassesDirs = sourceSets.functionalTest.output.classesDirs
classpath = sourceSets.functionalTest.runtimeClasspath
}

if(!ext.testCategory) {
Expand Down Expand Up @@ -336,6 +373,15 @@ plugins.withType(GroovyBasePlugin) {
* Deployment
*
***********************************************************************************************************************/
gradlePlugin {
testSourceSets sourceSets.test
plugins {
vaadinPlugin {
id = 'com.devsoap.plugin.vaadin'
implementationClass = 'com.devsoap.plugin.GradleVaadinPlugin'
}
}
}

pluginBundle {
website = 'https://github.com/johndevs/gradle-vaadin-plugin/wiki'
Expand All @@ -344,7 +390,7 @@ pluginBundle {
tags = ['vaadin', 'java', 'groovy', 'kotlin']
plugins {
vaadinPlugin {
id = 'com.devsoap.plugin.vaadin'
id = gradlePlugin.plugins.vaadinPlugin.id
displayName = 'Gradle Vaadin plugin'
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.devsoap.plugin.tests

import com.devsoap.plugin.categories.ThemeCompile

import com.devsoap.plugin.categories.WidgetsetCompile
import com.devsoap.plugin.tasks.CompileWidgetsetTask
import com.devsoap.plugin.tasks.CreateComponentTask
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.devsoap.plugin.tests
import com.devsoap.plugin.tasks.CreateAddonThemeTask
import org.junit.Assert
import org.junit.Test
import org.junit.experimental.categories.Category

import java.nio.file.Paths

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import org.junit.runner.RunWith
import org.junit.runners.Parameterized

import java.nio.file.Paths
import static org.junit.Assert.assertTrue

import static org.junit.Assert.assertFalse
import static org.junit.Assert.assertTrue

/**
* Created by john on 18.1.2016.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,6 @@ class IntegrationTest {
}

protected GradleRunner setupRunner(File projectDir = this.projectDir.root) {
GradleRunner.create().withProjectDir(projectDir)
GradleRunner.create().withProjectDir(projectDir).withPluginClasspath()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/
package com.devsoap.plugin.tests

/**
* Base for tests tests which has modules with vaadin projects
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import org.junit.Test
import org.junit.experimental.categories.Category

import java.nio.file.Paths
import java.util.concurrent.TimeUnit
import java.util.jar.Manifest

import static org.junit.Assert.assertNotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class ProjectDependenciesTest extends IntegrationTest {
assertFalse result, result.contains( 'Version blacklist failed for')
}

@Test void 'Maven Central/Local are included'() {
@Test void 'Maven Central and Local are included'() {

buildFile << """
task testMavenCentralLocal {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package com.devsoap.plugin.tests

import com.devsoap.plugin.GradleVaadinPlugin
import com.devsoap.plugin.categories.WidgetsetCompile
import com.devsoap.plugin.tasks.CreateProjectTask
import org.junit.Test
import org.junit.experimental.categories.Category
import org.junit.runner.RunWith
import org.junit.runners.Parameterized

Expand Down

0 comments on commit 7025dd9

Please sign in to comment.