Closed BalurQA closed 5 years ago
Hi @BalurQA, I am not sure I understand the question. Can you clarify what you want to achieve or provide a small example project? Do you want to exclude specific specifications from the report?
@tilmanginzel : Do you want to exclude specific specifications from the report? : Yes I want to exclude some specific specifications from the report or report should show only scripts executed from specific package.
Again I want to maintain execution result(index.html) for every job which i trigger.
Hi @BalurQA, sorry for the late response, quite busy lately.
I want to exclude some specific specifications from the report
How would you expect to use the exclusion? I could imagine some kind of configuration file where you can define all classes which should not be part of the generated report.
or report should show only scripts executed from specific package
This is basically already exactly what is happening when you execute just a specific package containing specs. But, keep in mind that new executions of (other) specifications just add up to the report if no ./gradlew clean
was executed in between:
There is no way to change this.
I want to maintain execution result(index.html) for every job which i trigger
I still don't entirely understand what you mean by this. If I understand correctly, you can already do this in Jenkins via publishing the results each time the jenkins job is executed. Locally, I don't think it is possible. Do you want to copy/archive the complete report folder after executing the tests?
@tilmanginzel Yes I want to copy/archive the complete report folder after executing the tests. Report folder should be based on date and time stamp.
Hey @BalurQA, sorry for the late response, was on vacation.
I don't think that this export should be part of the library as it is very specific, but you can easily achieve this on your own. Just add the following to your build.gradle
(adjust the paths if necessary):
import org.apache.commons.io.FileUtils
// ...
dependencies {
// ...
compileOnly group: 'commons-io', name: 'commons-io', version: '2.6'
}
task exportGebSpockReports {
doLast {
def srcDir = new File("build/geb-spock-reports")
def timestamp = Instant.now()
def target = new File("exports/$timestamp-geb-spock-reports")
FileUtils.copyDirectory(srcDir, target)
}
}
test.finalizedBy(exportGebSpockReports)
Now, each time you run ./gradlew test
, the complete geb-spock-reports folder will be copied. I hope that fulfills your needs. :)
@tilmanginzel : file import is not working in gradle file. Am I doing something wrong in copying this to gardle file. import org.apache.commons.io.FileUtils
Hm, have you added the commons-io dependency?
compileOnly group: 'commons-io', name: 'commons-io', version: '2.6'
Yes I have added the above mentioned dependency.
Is the error only shown by IntelliJ (might indicate a missing gradle refresh)? What is the exact error when you run a gradle task via command line?
I am getting above error when i was try clean the project in intellij.
Below is my complete gradle file.
ext {
gebVersion = '3.0.1'
groovyVersion = '2.4.12'
seleniumVersion = '3.14.0'
spockVersion = '1.1-groovy-2.4-rc-4'
}
buildscript {
repositories {
maven { url 'http://test/repositories/central/' }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.3.3.RELEASE")
}
}
apply plugin: 'groovy'
apply plugin: 'idea'
apply plugin: 'spring-boot'
jar {
baseName = 'test-app-qa'
}
repositories {
mavenCentral()
jcenter()
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
testCompile 'com.aoe:geb-spock-reports:0.2.5'
testCompile ("com.athaydes:spock-reports:1.6.2") { transitive = false }
compileOnly group: 'commons-io', name: 'commons-io', version: '2.6'
compile "org.codehaus.groovy:groovy-all:${groovyVersion}"
compile 'org.springframework.boot:spring-boot-starter-web'
compile 'org.springframework.boot:spring-boot-starter-thymeleaf'
compile 'org.springframework.boot:spring-boot-starter-actuator'
// spring cloud
compile 'org.webjars:bootstrap:3.3.6'
compile 'org.webjars:webjars-locator:0.30'
testCompile "org.springframework.boot:spring-boot-starter-test"
compile "org.skyscreamer:jsonassert:1.5.0"
compile "com.google.guava:guava:22.0"
testCompile "org.spockframework:spock-core:${spockVersion}"
testCompile "org.spockframework:spock-spring:${spockVersion}"
testCompile 'org.springframework:spring-test'
testCompile "org.gebish:geb-spock:${gebVersion}"
testCompile "org.seleniumhq.selenium:selenium-chrome-driver:${seleniumVersion}"
testCompile "org.seleniumhq.selenium:selenium-firefox-driver:${seleniumVersion}"
testCompile "org.seleniumhq.selenium:selenium-ie-driver:${seleniumVersion}"
testCompile "org.seleniumhq.selenium:selenium-edge-driver:${seleniumVersion}"
testCompile "org.seleniumhq.selenium:selenium-safari-driver:${seleniumVersion}"
testCompile "org.seleniumhq.selenium:selenium-remote-driver:${seleniumVersion}"
testCompile "org.seleniumhq.selenium:selenium-support:${seleniumVersion}"
// For downloading browser-specific drivers that browsers like Chrome and IE require
testCompile("io.github.bonigarcia:webdrivermanager:3.6.2") {
exclude group: 'org.seleniumhq.selenium'
}
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-starter-parent:Brixton.RELEASE" //TO-DO: update version
}
}
tasks.withType(Test) {
systemProperty 'spring.profiles.active', 'qa2_eu' //by default run on qa3 us
systemProperty 'eureka.client.enabled', 'true'
systemProperty 'spring.cloud.config.label', 'dev'
systemProperty 'geb.env', 'chrome' //by default run on Chrome
systemProperty 'geb.build.reportsDir', 'build/test-reports'
testLogging {
exceptionFormat "full"
events "PASSED", "FAILED", "SKIPPED"
}
}
task wrapper(type: Wrapper) {
gradleVersion = '4.10'
}
import org.apache.commons.io.FileUtils
task exportGebSpockReports {
doLast {
def srcDir = new File("build/geb-spock-reports")
def timestamp = Instant.now()
def target = new File("exports/$timestamp-geb-spock-reports")
FileUtils.copyDirectory(srcDir, target)
}
}
test.finalizedBy(exportGebSpockReports)
// Pass system properties through to the test task so we can pass in the 'geb.env' property to run tests
// in different browsers. Adapted from http://mrhaki.blogspot.com/2015/09/grails-goodness-passing-system.html
configure(test) {
systemProperties System.properties
}
Hmm, I am clueless here. Some trial-and-error thoughts:
compileOnly
to compile
@tilmanginzel : Still facing the issue evening after downgrading the version to 2.4
Build file 'C:\Users\\test\build.gradle' line: 110
* What went wrong:
Execution failed for task ':exportGebSpockReports'.
> Could not find property 'Instant' on task ':exportGebSpockReports'.
Which Java and Gradle version are you using? Instant
was added in Java 8. Maybe import java.time.Instant
helps, but it wasn't necessary in my case.
For what it's worth, I just copied your build.gradle
content above (commented out some dependencies), and it was working just fine.
Gradle 4.10 java version "1.8.0_172"
Even I have same gradle version 4.10 and JAVA version in my system is "1.8.0_181".
Can you copy paste the working build.gradle
content here. I will try my side and update.
Hi @BalurQA, while creating a fresh gradle project I was facing the same issue. I am not entirely sure why it was working in my previous sample project, but this bit seems to be required:
buildscript {
dependencies {
classpath "commons-io:commons-io:2.6"
}
}
The compileOnly
dependency is not necessary. Regarding the Instant
issue, this should resolve it:
import java.time.Instant
If you still face any issues, I will provide a full working example.
Hi @tilmanginzel , I will try above solution and let you know the status. Thank you for your time.
@tilmanginzel : Yeah it did work with above solution and slight modification below
replace code Instant.now()
with System.currentTimeMillis()
Instant.now() was giving full system date with (.) in the string, so it was not creating the folder hence replaced it to keep the string without any spaces and special characters.
you are awesome.
Happy to hear that it's working now! :) I assume we can close this issue then?
closing the issue. Thank you again.
Hi, I am using this report for Geb automation and I liked it.
I want to keep log all execution reports in Jenkins and local copy also when executed.
The report is showing specification(ex: BaseSpec) file as one test case which i do not want to show in the report.
Could you please help me here.
Thank you