multiple testng test listeners running using gradle test command - gradle

I have 2 custom listeners implementing ITestListener, ISuiteListener, IInvokedMethodListener . when I run the command from gradle as gradle clean --test testname . it runs both listeners though I have only one class defined in the #Listeners annotation in test. Its a gradle project but when I run the test in intellij as testng test it runs with only 1 listener as expected. Can you please tell how to make it run with only 1 listener using gradle command
my build.gradle below and testng version I am using is 6.9.4 and I tried 6.9.10 too
ext {
unitTestingMinHeapSize = "512m"
}
// Apply the java plugin to add support for Java
apply plugin: 'java'
// Apply the application plugin to add support for building an application
apply plugin: 'application'
// Apply the eclipse plugin to add support for building on eclipse
apply plugin: 'eclipse'
// Apply the idea plugin to add support for building on IDEA
apply plugin: 'idea'
// In this section you declare where to find the dependencies of your project
repositories {
// Use 'jcenter' for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
mavenCentral()
mavenLocal()
}
// In this section you declare the dependencies for your production and test code
dependencies {
compile project(':oos')
testCompile project(':oos')
compile "commons-pool:commons-pool:$apacheCommonsPool1Version"
compile "org.apache.commons:commons-lang3:$apacheCommonsLangVersion"
compile "org.apache.commons:commons-pool2:$apacheCommonsPool2Version"
compile "com.rabbitmq:amqp-client:$rabbitMQClientVersion"
compile "redis.clients:jedis:$jedisVersion"
compile "org.apache.httpcomponents:httpclient:$httpClientVersion"
compile "org.apache.httpcomponents:httpmime:$httpmimeversion"
compile "io.rest-assured:rest-assured:$restAssuredVersion"
compile "org.hamcrest:hamcrest-all:$hamcrestVersion"
compile "org.postgresql:postgresql:$postgresqlversion"
compile "com.googlecode.json-simple:json-simple:1.1.1"
compile "com.codepine.api:testrail-api-java-client:1.0.2"
testCompile "org.mockito:mockito-all:$mockitoVersion"
testCompile "org.springframework:spring-test:$springVersion"
compile ("org.testng:testng:$testngVersion") {
exclude group: "junit", module: "junit"
}
testCompile "org.apache.commons:commons-pool2:$apacheCommonsPool2Version"
}
test {
for (String key : System.getProperties().keySet()) {
systemProperty key, System.properties["$key"]
}
jvmArgs "-XX:-UseSplitVerifier"
systemProperty "runId", findProperty("runId")
useTestNG { useDefaultListeners = true }
beforeTest { descriptor ->
logger.lifecycle("Running: " + descriptor)
}
minHeapSize = "$unitTestingMinHeapSize"
jvmArgs '-XX:+UseConcMarkSweepGC', '-XX:+CMSIncrementalMode' //,'-XX:+PrintGCDetails','-XX:+PrintGCTimeStamps'
if (System.getProperty("test.profile", "false").equals("true")) {
jvmArgs "-noverify", "-agentpath:${profilerDir}/lib/deployed/jdk16/mac/libprofilerinterface.jnilib=${profilerDir}/lib,5140,0"
}
// listen to standard out and standard error of the test JVM(s)
onOutput { descriptor, event ->
// logger.lifecycle("Test: " + descriptor + " produced standard out/err: " + event.message )
if (event.destination == TestOutputEvent.Destination.StdErr) {
logger.error(" ERROR: " + event.message.trim())
}
}
}

Related

Custom Gradle War Task Can't Find Zip

:internal-tools:reWar FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Cannot expand ZIP '/Users/XXXXXX/Documents/XXXX/XXXX/internal-tools/internal-tools-195.0-SNAPSHOT.war' as it does not exist.
internal-tools.gradle
description = 'Internal Tools'
ext {
grailsVersion = "3.3.3"
}
apply plugin: "org.grails.grails-web"
apply plugin: "war"
apply plugin:"org.grails.grails-gsp"
grails {
grailsVersion = "3.3.3"
//springLoadedVersion = '1.2.4.RELEASE'
}
configurations.all {
// already provided by the JVM, Grails complains if classes show up twice in the classpath
exclude group: 'xml-apis', module: 'xml-apis'
exclude module: 'grails-plugin-log4j'
//provided servlet container
exclude group: 'javax.el', module: 'el-api'
exclude group: 'org.glassfish.web', module: 'el-impl'
}
dependencies {
compile project(':business-logic')
//test(project(path: ':business-logic', configuration: 'testArtifacts'))
def slf4jVersion = '1.7.2'
compile "org.slf4j:jcl-over-slf4j:${slf4jVersion}"
compile "org.slf4j:jul-to-slf4j:${slf4jVersion}"
compile "org.slf4j:slf4j-api:${slf4jVersion}"
// We force a newer version of Ant to work around a bug in the Oracle JRE. This can be removed when Grails upgrades Ant
// See Ant 'Bug 54641' for more details
runtime "org.apache.ant:ant:1.9.2"
runtime "org.apache.ant:ant-junit:1.9.2"
// Grails
runtime "org.grails:grails-dependencies:$grailsVersion"
compile "org.grails:grails-plugin-validation:3.3.3"
compile 'org.grails.plugins:converters:4.0.0'
compile 'org.grails.plugins:gorm-tools:6.1.11-v.12'
compile "org.grails:grails-plugin-databinding"
compile "org.springframework.boot:spring-boot-starter-logging"
compile "org.springframework.boot:spring-boot-autoconfigure"
compile "org.springframework.boot:spring-boot-starter-actuator"
compile "org.springframework.boot:spring-boot-starter-tomcat"
compile "org.grails:grails-web-boot"
compile "org.grails:grails-core"
// Grails plugins
compile "org.grails.plugins:hibernate4:4.3.6.1"
compile "org.grails.plugins:tomcat:7.0.55"
compile "org.grails.plugins:export:1.6"
compile "org.grails.plugins:webflow:2.1.0"
compile 'org.grails.plugins:logback:0.3.1'
runtime "org.grails:grails-plugin-validation:$grailsVersion"
//test "org.grails:grails-test:$grailsVersion"
// test "org.grails:grails-plugin-testing:$grailsVersion"
// test 'org.hamcrest:hamcrest-all:1.1'
//test 'org.mockito:mockito-all:1.8.0'
// test 'nekohtml:nekohtml:1.9.6.2'
// bootstrap 'ch.qos.logback:logback-classic:1.1.3'
}
test {
doFirst {
tasks.getByPath(':dbTestCreate').ext.testDatabase.create()
}
dependsOn(':configProperties')
jvmArgs '-XX:MaxMetaspaceSize=256m'
systemProperty 'XXXX.conf.file', "$configOutputDir/XXXX_test.properties"
String protocol = "file:"
systemProperty 'logback.configurationFile', protocol + new File(rootProject.projectDir,"dev/log/logback.xml").getAbsolutePath()
}
bootRun {
dependsOn(':configProperties', ':dbValidate')
jvmArgs '-XX:MaxMetaspaceSize=256m'
systemProperty 'XXXX.conf.file', "$configOutputDir/XXXX_dev.properties"
String protocol = "file:"
systemProperty 'logback.configurationFile', protocol + new File(rootProject.projectDir,"dev/log/logback.xml").getAbsolutePath()
}
war {
String protocol = "file:"
//systemProperty 'logback.configurationFile', protocol + new File(rootProject.projectDir,"dev/log/logback.xml").getAbsolutePath()
}
// We re-package the war so it will include the extra GradleCM meta-info.
// We use a zip task rather than a war task because the war task adds extra files such as a second web.xml
task reWar(type: Zip, dependsOn: ['war']) {
destinationDir = file("$buildDir/libs")
extension = 'war'
// HACK: the input needs to be wrapped in a closure so it is evaluated lazily. This is because the 'war' task output
// file changes once the version is set
from { zipTree(war.archiveName) }
//
// Build info file
//
from (rootProject.buildinfo.filedir) {
include rootProject.buildinfo.filename
into 'META-INF'
}
}
artifacts {
archives reWar
}
// Ensure tests are run for uploadArchives
uploadArchives.dependsOn('check')
buildscript {
repositories {
maven { url "https://repo1.maven.org/maven2/" }
maven { url "https://dl.bintray.com/jfrog/jfrog-jars/" }
maven { url "https://repo.gradle.org/gradle/libs-releases-local/" }
//maven { url "https://repo.spring.io/plugins-release/" }
maven { url "https://repo.maven.apache.org/maven2/" }
maven { url "https://repo.grails.org/grails/core" }
mavenCentral()
}
dependencies {
classpath "org.grails:grails-gradle-plugin:3.3.3"
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.+"
classpath "org.gradle:gradle-tooling-api:5.+"
classpath "org.codehaus.groovy.modules.http-builder:http-builder:0.7.+"
//classpath "org.grails.plugins:hibernate4:${gormVersion-".RELEASE"}"
}
}
Can anyone help me with my reWar task? I think it is a custom task. I need it to look here instead '/Users/XXXXXX/Documents/XXXX/XXXX/internal-tools/build/internal-tools-195.0-SNAPSHOT.war' . It seems to be looking here '/Users/XXXXXX/Documents/XXXX/XXXX/internal-tools/internal-tools-195.0-SNAPSHOT.war'

How to run grails integration tests with gradle

Old internal-tools.gradle
description = 'Internal Tools'
ext {
grailsVersion = "2.4.4"
}
apply plugin: "grails"
grails {
grailsVersion = "2.4.4"
springLoadedVersion = '1.2.4.RELEASE'
}
configurations.all {
// already provided by the JVM, Grails complains if classes show up twice in the classpath
exclude group: 'xml-apis', module: 'xml-apis'
exclude module: 'grails-plugin-log4j'
//provided servlet container
exclude group: 'javax.el', module: 'el-api'
exclude group: 'org.glassfish.web', module: 'el-impl'
}
dependencies {
compile project(':business-logic')
test(project(path: ':business-logic', configuration: 'testArtifacts'))
def slf4jVersion = '1.7.2'
compile "org.slf4j:jcl-over-slf4j:${slf4jVersion}"
compile "org.slf4j:jul-to-slf4j:${slf4jVersion}"
compile "org.slf4j:slf4j-api:${slf4jVersion}"
// We force a newer version of Ant to work around a bug in the Oracle JRE. This can be removed when Grails upgrades Ant
// See Ant 'Bug 54641' for more details
runtime "org.apache.ant:ant:1.9.2"
runtime "org.apache.ant:ant-junit:1.9.2"
// Grails
runtime "org.grails:grails-dependencies:$grailsVersion"
// Grails plugins
compile "org.grails.plugins:hibernate4:4.3.6.1"
compile "org.grails.plugins:tomcat:7.0.55"
compile "org.grails.plugins:export:1.6"
compile "org.grails.plugins:webflow:2.1.0"
compile 'org.grails.plugins:logback:0.3.1'
runtime "org.grails:grails-plugin-validation:$grailsVersion"
test "org.grails:grails-test:$grailsVersion"
test "org.grails:grails-plugin-testing:$grailsVersion"
test 'org.hamcrest:hamcrest-all:1.1'
test 'org.mockito:mockito-all:1.8.0'
test 'nekohtml:nekohtml:1.9.6.2'
bootstrap 'ch.qos.logback:logback-classic:1.1.3'
}
test {
doFirst {
tasks.getByPath(':dbTestCreate').ext.testDatabase.create()
}
dependsOn(':configProperties')
jvmOptions.jvmArgs '-XX:MaxMetaspaceSize=256m'
jvmOptions.systemProperty('XXXX.conf.file', "$configOutputDir/XXXX_test.properties")
String protocol = "file:"
jvmOptions.systemProperty 'logback.configurationFile', protocol + new File(rootProject.projectDir,"dev/log/logback.xml").getAbsolutePath()
}
'grails-run-app' {
dependsOn(':configProperties', ':dbValidate')
jvmOptions.jvmArgs '-XX:MaxMetaspaceSize=256m'
jvmOptions.systemProperty('XXXX.conf.file', "$configOutputDir/XXXX_dev.properties")
String protocol = "file:"
jvmOptions.systemProperty 'logback.configurationFile', protocol + new File(rootProject.projectDir,"dev/log/logback.xml").getAbsolutePath()
}
war {
String protocol = "file:"
jvmOptions.systemProperty 'logback.configurationFile', protocol + new File(rootProject.projectDir,"dev/log/logback.xml").getAbsolutePath()
}
// We re-package the war so it will include the extra GradleCM meta-info.
// We use a zip task rather than a war task because the war task adds extra files such as a second web.xml
task reWar(type: Zip, dependsOn: ['war']) {
destinationDir = file("$buildDir/libs")
extension = 'war'
// HACK: the input needs to be wrapped in a closure so it is evaluated lazily. This is because the 'war' task output
// file changes once the version is set
from { zipTree(war.outputFile) }
//
// Build info file
//
from (rootProject.buildinfo.filedir) {
include rootProject.buildinfo.filename
into 'META-INF'
}
}
artifacts {
archives reWar
}
// Ensure tests are run for uploadArchives
uploadArchives.dependsOn('check')
buildscript {
repositories {
maven {
url "http://nexus.XXXXX.com/content/groups/public/"
}
}
dependencies {
classpath "org.grails:grails-gradle-plugin:2.1.2"
}
}
New internal-tools.gradle
description = 'Internal Tools'
ext {
grailsVersion = "3.3.3"
}
apply plugin: "org.grails.grails-web"
apply plugin: "war"
apply plugin:"org.grails.grails-gsp"
grails {
grailsVersion = "3.3.3"
//springLoadedVersion = '1.2.4.RELEASE'
}
configurations.all {
// already provided by the JVM, Grails complains if classes show up twice in the classpath
exclude group: 'xml-apis', module: 'xml-apis'
exclude module: 'grails-plugin-log4j'
//provided servlet container
exclude group: 'javax.el', module: 'el-api'
exclude group: 'org.glassfish.web', module: 'el-impl'
}
dependencies {
compile project(':business-logic')
//test(project(path: ':business-logic', configuration: 'testArtifacts'))
def slf4jVersion = '1.7.2'
compile "org.slf4j:jcl-over-slf4j:${slf4jVersion}"
compile "org.slf4j:jul-to-slf4j:${slf4jVersion}"
compile "org.slf4j:slf4j-api:${slf4jVersion}"
// We force a newer version of Ant to work around a bug in the Oracle JRE. This can be removed when Grails upgrades Ant
// See Ant 'Bug 54641' for more details
runtime "org.apache.ant:ant:1.9.2"
runtime "org.apache.ant:ant-junit:1.9.2"
// Grails
runtime "org.grails:grails-dependencies:$grailsVersion"
compile "org.grails:grails-plugin-validation:3.3.3"
compile 'org.grails.plugins:converters:4.0.0'
compile 'org.grails.plugins:gorm-tools:6.1.11-v.12'
compile "org.grails:grails-plugin-databinding"
compile "org.springframework.boot:spring-boot-starter-logging"
compile "org.springframework.boot:spring-boot-autoconfigure"
compile "org.springframework.boot:spring-boot-starter-actuator"
compile "org.springframework.boot:spring-boot-starter-tomcat"
compile "org.grails:grails-web-boot"
compile "org.grails:grails-core"
// Grails plugins
compile "org.grails.plugins:hibernate4:4.3.6.1"
compile "org.grails.plugins:tomcat:7.0.55"
compile "org.grails.plugins:export:1.6"
compile "org.grails.plugins:webflow:2.1.0"
compile 'org.grails.plugins:logback:0.3.1'
runtime "org.grails:grails-plugin-validation:$grailsVersion"
//test "org.grails:grails-test:$grailsVersion"
// test "org.grails:grails-plugin-testing:$grailsVersion"
// test 'org.hamcrest:hamcrest-all:1.1'
//test 'org.mockito:mockito-all:1.8.0'
// test 'nekohtml:nekohtml:1.9.6.2'
// bootstrap 'ch.qos.logback:logback-classic:1.1.3'
}
test {
doFirst {
tasks.getByPath(':dbTestCreate').ext.testDatabase.create()
}
dependsOn(':configProperties')
jvmArgs '-XX:MaxMetaspaceSize=256m'
systemProperty 'XXXX.conf.file', "$configOutputDir/XXXX_test.properties"
String protocol = "file:"
systemProperty 'logback.configurationFile', protocol + new File(rootProject.projectDir,"dev/log/logback.xml").getAbsolutePath()
}
bootRun {
dependsOn(':configProperties', ':dbValidate')
jvmArgs '-XX:MaxMetaspaceSize=256m'
systemProperty 'XXXX.conf.file', "$configOutputDir/XXXX_dev.properties"
String protocol = "file:"
systemProperty 'logback.configurationFile', protocol + new File(rootProject.projectDir,"dev/log/logback.xml").getAbsolutePath()
}
war {
String protocol = "file:"
//systemProperty 'logback.configurationFile', protocol + new File(rootProject.projectDir,"dev/log/logback.xml").getAbsolutePath()
}
// We re-package the war so it will include the extra GradleCM meta-info.
// We use a zip task rather than a war task because the war task adds extra files such as a second web.xml
task reWar(type: Zip, dependsOn: ['war']) {
destinationDir = file("$buildDir/libs")
extension = 'war'
// HACK: the input needs to be wrapped in a closure so it is evaluated lazily. This is because the 'war' task output
// file changes once the version is set
from { zipTree(war.archivePath) }
//
// Build info file
//
from (rootProject.buildinfo.filedir) {
include rootProject.buildinfo.filename
into 'META-INF'
}
}
artifacts {
archives reWar
}
// Ensure tests are run for uploadArchives
uploadArchives.dependsOn('check')
buildscript {
repositories {
maven { url "https://repo1.maven.org/maven2/" }
maven { url "https://dl.bintray.com/jfrog/jfrog-jars/" }
maven { url "https://repo.gradle.org/gradle/libs-releases-local/" }
//maven { url "https://repo.spring.io/plugins-release/" }
maven { url "https://repo.maven.apache.org/maven2/" }
maven { url "https://repo.grails.org/grails/core" }
mavenCentral()
}
dependencies {
classpath "org.grails:grails-gradle-plugin:3.3.3"
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.+"
classpath "org.gradle:gradle-tooling-api:5.+"
classpath "org.codehaus.groovy.modules.http-builder:http-builder:0.7.+"
//classpath "org.grails.plugins:hibernate4:${gormVersion-".RELEASE"}"
}
}
I had to upgrade gradle from 2.2 to 3.5. One of the gradle modules I have is a grails app called internal-tools. I posted the old build.gradle we used and the new one I am still working on. I had to change some of it around after upgrading gradle to 3.5.
The old internal-tools.gradle used to start up the application and run through a series of integration tests. My new internal-tools.gradle is not starting up the application and running through the integration tests. I was wondering if anyone had any ideas or ran into the same problem upgrading gradle and grails. I inherited this project so I'm not 100% sure what these gradle files are doing.
If the 'grails-run-app' task is what started it up in the old gradle file what is the equivalent I can use in gradle 3.5? I tried putting the same things in a "bootRun" task but that doesn't seem to work. It could be related to an issue I was having where the app thought it was spring boot so I had to stick a public static void main in there so the ":internal-tools:findMainClass" would work.
Actually the more I look at it I think the grails-run-app was just used to start up the application after it was built. So I'm not sure what started up the application and ran the integration tests in the old gradle file, and how I can reproduce the same thing with gradle 3.5

Error using Gradle Vaadin Plugin

I am trying to add Gradle Vaadin Plugin to my project, but I get the below error.
Errors in 'jar:file:/C:/Users/DEMO/.gradle/caches/modules-2/files-2.1/com.google.gwt/gwt-user/2.8.1/9a13fbee70848f1f1cddd3ae33ad180af3392d9e/gwt-user-2.8.1.jar!/com/google/gwt/vali
dation/client/impl/GwtValidatorContext.java'
Line 29: The type GwtValidatorContext must implement the inherited abstract method ValidatorContext.parameterNameProvider(ParameterNameProvider)
Tracing compile failure path for type 'com.vaadin.client.communication.AtmospherePushConnection'
Errors in 'jar:file:/C:/Users/DEMO/.m2/repository/com/vaadin/vaadin-client/8.0.6/vaadin-client-8.0.6.jar!/com/vaadin/client/communication/AtmospherePushConnection.java'
Line 212: PUSH_ID_PARAMETER cannot be resolved or is not a field
Tracing compile failure path for type 'javax.validation.executable.ExecutableValidator'
Errors in 'jar:file:/C:/Users/DEMO/.gradle/caches/modules-2/files-2.1/javax.validation/validation-api/1.1.0.Final/7d49b53caed9bd81d172807c3e096d24f3c57090/validation-api-1.1.0.Fina
l-sources.jar!/javax/validation/executable/ExecutableValidator.java'
Line 53: No source code is available for type java.lang.reflect.Method; did you forget to inherit a required module?
Line 94: No source code is available for type java.lang.reflect.Constructor<T>; did you forget to inherit a required module?
Tracing compile failure path for type 'com.vaadin.client.communication.MessageHandler'
Errors in 'jar:file:/C:/Users/DEMO/.m2/repository/com/vaadin/vaadin-client/8.0.6/vaadin-client-8.0.6.jar!/com/vaadin/client/communication/MessageHandler.java'
Line 358: UIDL_PUSH_ID cannot be resolved or is not a field
Line 359: UIDL_PUSH_ID cannot be resolved or is not a field
Tracing compile failure path for type 'com.google.gwt.validation.client.impl.PropertyDescriptorImpl'
Errors in 'jar:file:/C:/Users/DEMO/.gradle/caches/modules-2/files-2.1/com.google.gwt/gwt-user/2.8.1/9a13fbee70848f1f1cddd3ae33ad180af3392d9e/gwt-user-2.8.1.jar!/com/google/gwt/vali
dation/client/impl/PropertyDescriptorImpl.java'
Line 31: The type PropertyDescriptorImpl must implement the inherited abstract method CascadableDescriptor.getGroupConversions()
Errors in 'jar:file:/C:/Users/DEMO/.gradle/caches/modules-2/files-2.1/com.google.gwt/gwt-user/2.8.1/9a13fbee70848f1f1cddd3ae33ad180af3392d9e/gwt-user-2.8.1.jar!/com/google/gwt/vali
dation/client/impl/ConstraintDescriptorImpl.java'
Line 35: The type ConstraintDescriptorImpl<T> must implement the inherited abstract method ConstraintDescriptor<T>.getMessageTemplate()
Line 35: The type ConstraintDescriptorImpl<T> must implement the inherited abstract method ConstraintDescriptor<T>.getValidationAppliesTo()
Tracing compile failure path for type 'com.google.gwt.validation.client.impl.GwtBeanDescriptorImpl'
Here is the page for the plugin: https://github.com/johndevs/gradle-vaadin-plugin/wiki
And, here is my build.gradle file:
buildscript {
ext {
springBootVersion = '1.5.3.RELEASE'
}
repositories {
mavenCentral()
maven {
url "http://maven.vaadin.com/vaadin-addons"
}
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
plugins {
id 'com.devsoap.plugin.vaadin' version '1.2.1'
id 'org.springframework.boot' version '1.5.3.RELEASE'
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'jacoco'
apply plugin: 'application'
jar {
baseName = 'testapp'
version = '0.0.1-SNAPSHOT'
}
sourceCompatibility = 1.8
repositories {
mavenCentral()
flatDir {
dirs 'libs'
}
maven {
url "http://maven.vaadin.com/vaadin-addons"
}
}
sourceSets {
main {
output.resourcesDir = "build/classes/main"
}
uiTest {
java.srcDirs=['src/ui-test/java','src/main/java']
resources.srcDir 'src/ui-test/resources'
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
}
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-jersey')
compile('org.springframework.boot:spring-boot-starter-web')
testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile('org.springframework.restdocs:spring-restdocs-mockmvc')
// Spring Boot Security
compile("org.springframework.boot:spring-boot-starter-security")
compile("org.springframework.security.oauth:spring-security-oauth2")
compile('org.springframework.security:spring-security-ldap')
// Spring Actuator
compile("org.springframework.boot:spring-boot-starter-actuator")
// Spring Boot JDBC Starter
compile("org.springframework.boot:spring-boot-starter-jdbc")
// Vaadin
compile('com.vaadin:vaadin-spring-boot-starter')
compile('com.vaadin:vaadin-push')
// Vaadin add-ons
compile("org.vaadin.spring.addons:vaadin-spring-addon-eventbus:2.0.0.RELEASE")
//Vaadin extentions
compile("org.vaadin.spring.extensions:vaadin-spring-ext-security:2.0.0.RELEASE")
// Lombok
compile("org.projectlombok:lombok")
// MyBatis
compile("org.mybatis:mybatis-spring:1.2.3")
compile("org.mybatis:mybatis:3.3.0")
// BoneCP - Connection Pooling
compile("com.jolbox:bonecp:0.8.0.RELEASE")
// PostgreSQL
compile("org.postgresql:postgresql:9.4-1204-jdbc42")
//Vaadin Testbench
uiTestCompile("com.vaadin:vaadin-testbench:5.0.0")
//TypeAhead widget
compile name: 'typeaheadSearchBox-1.0-SNAPSHOT'
}
// Create a new task called uiTest and set its type to Test.
// Configure the location of the compiled test classes.
// Configure the classpath that is used when our integration tests are run.
configurations {
uiTestCompile.extendsFrom testCompile
uiTestRuntime.extendsFrom testRuntime
}
task uiTest(type: Test) {
testClassesDir = sourceSets.uiTest.output.classesDir
classpath = sourceSets.uiTest.runtimeClasspath
}
dependencyManagement {
imports {
mavenBom "com.vaadin:vaadin-bom:8.0.3"
}
}
jacocoTestReport {
reports {
xml.enabled = true
html.enabled = true
}
}
check.dependsOn jacocoTestReport
springBoot {
// Main class of #SpringBootApplication
mainClass = 'com.sample.test.Application'
}
When I check the gradle dependencies, I see 2 version of the "javax.validation:validation-api".
I believe that is causing the problem, but I could not find a way to force vaadin-client to use "javax.validation:validation-api:1.0.0.GA".
I appreciate if you can help me to correct the build.gradle.
The Gradle Vaadin plugin must see the Springboot plugin to do a proper setup. So you have to first use the Springboot plugin, then afterwards the Vaadin plugin.
The reason for the error you see there is, that the dep for javax.validation 1.1 from Springboot overrides all configurations (also the one used to build the client for Vaadin)
On a side note: you apply the Springboot plugin twice -- once in plugins, once with apply. I'd get rid of the buildscript-block and the apply. Then swap the items in plugins.

Getting Specs2 to shows results with Gradle

Having trouble getting Specs2 to work with Gradle, and the examples/advice I'm seeing around the place isn't really helping. The tests appear to be running, it's just that results aren't turning up (neither in the console nor the html report). What am I missing?
All the spec classes are decorated with
#RunWith(classOf[JUnitRunner])
The build.gradle looks as follows (java project, with scala/specs2 tests):
apply plugin: 'java'
apply plugin: 'scala'
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'org.jetbrains:annotations:15.0'
compile 'org.scala-lang:scala-library:2.11.7'
testCompile 'junit:junit:4.5'
testCompile "org.specs2:specs2-core_2.11:3.7.2"
testCompile "org.specs2:specs2-junit_2.11:3.7.2"
testCompile "org.apache.commons:commons-io:1.3.2"
}
repositories {
mavenCentral()
maven {
url "https://oss.sonatype.org/content/repositories/releases"
}
maven {
url "http://dl.bintray.com/scalaz/releases"
}
}
test {
testLogging.showStandardStreams = true
}
test {
onOutput { descriptor, event ->
logger.lifecycle("Test: " + descriptor + " produced standard out/err: " + event.message )
}
}
Based on what I'm reading and my own (admittedly limited) knowledge of gradle, this should work. What am I missing?
Edit:
Updating the specs2 version (changed above) helped.

No persistent classes found when integration test in Gradle

My project bases on Spring+JPA+Hibernate, and use Ant to manage build process before, now I am intending to use Gradle. While when run 'gradle clean test', I got a exception as below:
[2013-02-07 11:01:36,703][Test worker][WARN ][QuerySplitter] no persistent classes found for query class: from com.mpos.lottery.te.workingkey.domain.WorkingKey w where w.createDateStr=:createDateStr and w.gpeId=:gpeId
[2013-02-07 11:01:36,718][Test worker][ERROR][TEPortServlet] org.hibernate.QueryParameterException: could not locate named parameter [gpeId]; nested exception is java.lang.IllegalArgumentException: org.hibernate.QueryParameterException: could not locate named parameter [gpeId]
I have ran that test case(doesn't need jetty) in both eclipse and Ant, it passed, So i suspect that some incorrect configuration in gradle cause this exception.
Below is my gradle script:
apply plugin: 'war'
// 'war' plugin will apply 'java' plugin automatically
apply plugin: 'java'
apply plugin: 'eclipse'
// run web application, refer to http://gradle.org/docs/current/userguide/jetty_plugin.html
apply plugin: 'jetty'
compileJava.options.encoding = _sourcecode_encoding
compileTestJava.options.encoding = _sourcecode_encoding
// Properties added by the java plugin
sourceCompatibility="${_source_compatibility}"
targetCompatibility="${_target_compatibility}"
//Properties added by the 'war' plugin
webAppDirName="src/main/WWW"
configurations {
provided {
description = 'Non-exported comiple-time dependencies, it will be provided by container.'
}
}
dependencies {
provided files('lib/DEV/j2ee/servlet-api.jar')
compile fileTree(dir: 'lib', include: '**/*.jar', exclude: 'DEV/**/*.jar')
//compile sourceSets.main.output
testCompile fileTree(dir:"lib", include:"DEV/**/*.jar")
}
sourceSets {
main {
compileClasspath = compileClasspath + configurations.provided
//compileClasspath.collect().each({println it})
resources {
srcDir 'src/main/resource'
}
}
test {
resources {
srcDir 'src/test/resource'
}
}
}
test {
scanForTestClasses = false
classpath = configurations.provided + configurations.compile + configurations.testCompile + sourceSets.main.output + sourceSets.test.output
classpath.each({println it})
// customize test process
include 'com/mpos/lottery/te/gameimpl/smsraffle/**/*Test.class'
}
I am new learner of Gradle and groovy, pls help me. Thanks in advance.
By default, Gradle uses separate output directories for classes and resources, which can cause problems with Hibernate/JPA. Try:
sourceSets.main.output.resourcesDir = sourceSets.main.output.classesDir
sourceSets.test.output.resourcesDir = sourceSets.test.output.classesDir
You might not need the latter.

Resources