I have a gradle script to execute one one SOAPUI test suite. Currently the failed logs are coming in the same folder. I want to get all of the pass and failed logs to be create
I post this answer as a separate POST because I think that it's a good option for who doesn't have a PRO version, and good enough to have their space.
So the possible alternative is to generate the Junit Xml report files and then generate the Html using the Xml report and Xslt transformation.
To generate the Junit Xml report you can use the -j
parameter, and also -f
to specify the folder.
And then you can create a gradle task to perform the XSLT transformation (my solution is based on this solution on github).
So your build.gradle
could be:
repositories {
maven { url "http://repo.maven.apache.org/maven2" }
}
configurations {
antClasspath
}
// dependency for XMLResultAggregator task
dependencies {
antClasspath 'org.apache.ant:ant-junit:1.8.2'
}
class SoapUITask extends Exec {
String soapUIExecutable = '/SOAPUIpath/SoapUI-5.1.2/bin/testrunner.sh'
String soapUIArgs = ''
public SoapUITask(){
super()
this.setExecutable(soapUIExecutable)
}
public void setSoapUIArgs(String soapUIArgs) {
this.args = "$soapUIArgs".trim().split(" ") as List
}
}
// execute SOAPUI
task executeSOAPUI(type: SoapUITask){
def reportPath = 'path/of/outputReports'
soapUIArgs = '-f "' + reportPath + '" -j "/path/of/SOAPUI project xml/src/PCDEMO-soapui-project.xml"'
// perform the xslt
doLast {
soapuiXmlToHtml(reportPath)
}
}
// task to perform the XSLT
def soapuiXmlToHtml(resultsDir) {
def targetDir = new File(resultsDir, 'html')
ant.taskdef(
name: 'junitreport',
classname: 'org.apache.tools.ant.taskdefs.optional.junit.XMLResultAggregator',
classpath: configurations.antClasspath.asPath
)
ant.junitreport(todir: resultsDir) {
fileset(dir: resultsDir, includes: 'TEST-*.xml')
report(todir: targetDir, format: "frames")
}
}
Then you can invoke gradle executeSOAPUI
and your JUnit Html report will be generated on path/of/outputReports/html/
folder.
Hope it helps,