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
If you want to generate and HTML report from SOAPUI documentation you can use the follow parameters:
-f - Specifies the root directory, where the runner will save test result files. If the specified directory does not exist, it will be created.
-F Specifies the format of the exported reports. Usage: -F. Supported formats include PDF, XLS, HTML, RTF, CSV, TXT and XML. If the parameter is not specified, PDF is used. To export results in several formats, separate them with commas. For example, -FPDF,XML,CSV.
Note: As you can see on documentation the -F
parameter only works for PRO version. If you use the free version when you try to use -F
parameter you'll get the follow ouput:
org.apache.commons.cli.UnrecognizedOptionException: Unrecognized option: -FPDF
So you can modify task executeSOAPUI
to add -f location
and -FHTML
as follows:
// execute SOAPUI
task executeSOAPUI(type: SoapUITask){
// simply pass the project path as argument,
// note that the extra " are needed
soapUIArgs = '-f "path/of/outputReports" -FHTML "/path/of/SOAPUI project xml/src/PCDEMO-soapui-project.xml"'
}
If instead you are expecting a Junit Html style report you can try with the follow parameter (which is also only available in PRO version):
-R - Specifies the type of the report data.
Usage: -R. Report type can be one of the following:
Project Report - Generates a report in the format that is specified by the -F argument. The runner will save the report files to the directory that the -f argument specifies. Depending on the -A argument value, the files can be organized into subdirectories.
TestSuite Report - As above, but for TestSuites.
TestCase Report - As above, but for TestCases.
JUnit-Style HTML Report - Generates a report as JUnit-style HTML files. See JUnit-Style HTML Reports. When this value is used, the runner ignores the -F and -A arguments.
Data Export - Generates XML files with report data. See Data Export. When you use this argument, -F must be XML or must not be specified.
Use the -f argument to specify the directory, where the runner will save generated report files.
Using this your task
could be:
// execute SOAPUI
task executeSOAPUI(type: SoapUITask){
// simply pass the project path as argument,
// note that the extra " are needed
soapUIArgs = '-f "path/of/outputReports" -R"JUnit-Style HTML Report" "/path/of/SOAPUI project xml/src/PCDEMO-soapui-project.xml"'
}
Disclaimer: I don't have a PRO version so I can't test any of the options I give in the answer.
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,