Junit empty reports while running soapui testsuites using ant - junit

I am trying to run my testsuite using ant, for reporting I am using ant.
I did a lot of tries but unable to get the reports. My test suite is running properly, but my Junit report all values are 0.
My Build xml file
<?xml version="1.0"?>
<project basedir="." default="testreport" name="Automation">
<property name="results.dir" value="D:/airline.com/NDC_Automation/API/Results"/>
<property name="reports.dir" value="${results.dir}/Reports"/>
<property name="html.dir" value="${reports.dir}/html"/>
<property name="proj.dir" value="D:/airline.com/NDC_Automation/Project/ADC-NDC-SB8-soapui-project.xml"/>
<target name="testsuite1">
<exec dir="." executable="D:/SoapUI-5.2.1/bin/testrunner.bat">
<arg line="-r -j -a -f ${results.dir} -sDAC-3728 ${proj.dir}"/>
</exec>
</target>
<target name="testreport" depends="testsuite1">
<mkdir dir="${reports.dir}"/>
<junitreport todir="${reports.dir}">
<fileset dir="${results.dir}">
<include name="TEST-*.XML"/>
</fileset>
<report format="frames" todir="${html.dir}">
</report>
</junitreport>
</target>
</project>
I followed another post from stackoveflowTHIS POST and followed the steps mentioned in it as well. But still my junit report is empty.
My TESTS-TestSuites.XML
<?xml version="1.0" encoding="UTF-8" ?>
<testsuites />
Is my build file correct or have i missed any important tag ?

Related

Use a different JAVA_HOME when running JUnit through Ant

Currently, I am running Junit from Ant.
My environment variable JAVA_HOME is set to /path-to-jdk6 but I want the JUnit tests to run with /path-to-jdk8.
How do I set that?
This is my Ant target:
<target name="junit" depends="compile">
<junit printsummary="yes"
haltonfailure="no">
<classpath> <path refid="sample-classpath" /> </classpath>
<formatter type="plain" usefile="false" />
<batchtest todir="${junit.report.dir}">
<fileset dir="${build.classes.dir}">
<include name="**/*Test.class" />
</fileset>
</batchtest>
</junit>
</target>
You could wrap your JUnit task in a separate Ant exec task like so:
<macrodef name="exec-junit">
<attribute name="antfile" default="${ant.file}" />
<sequential>
<exec executable="ant">
<env key="JAVACMD" value="/path/to/jvm/1.8/bin/java" />
<arg line='-f "#{antfile}"' />
<arg line="junit" />
</exec>
</sequential>
</macrodef>
This uses the JAVACMD environment variable ...
JAVACMD - full path of the Java executable. Use this to invoke a different JVM than JAVA_HOME/bin/java(.exe).
The above target can then be invoked like so:
<target name="test">
<exec-junit/>
</target>

Empty Ant <junitreport> report for SoapUI testrunner XML results

I am running a SoapUI project using Ant to get a JUnit report.
Here is my build.xml:
<project basedir="." default="testreport" name="APIAutomation">
<target name="SoapUI">
<exec dir="." executable="C:\Program Files (x86)\SmartBear\SoapUI-5.0.0\bin\testrunner.bat">
<arg line="-r -j -a -f 'C:\Users\F3020722\Desktop\Notification\New folder' -sFirstLoginTest 'C:\Users\F3020722\Desktop\Notification\New folder\APIRegression.xml'"></arg>
</exec>
</target>
<target name="testreport" depends="SoapUI">
<junitreport todir="C:\Users\F3020722\Desktop\Notification\New folder\API">
<fileset dir="C:\Users\F3020722\Desktop\Notification\New folder\API">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames"
todir="C:\Users\F3020722\Desktop\Notification\New folder\reports\html">
</report>
</junitreport>
</target>
</project>
I am getting an XML report properly. However, the JUnit report is empty. all contains 0 and successrate is Nan.
Can anyone check the build.xml is correct?
Looks build script seems ok
Avoid spaces in the directory names
Use forward slashes like unix style even on windows
Use property file or properties in build script so that other members do not have it edit the build scripts as paths might change machine to machine.
For now, added properties in the below script, you may externalize to a property file too.
build.xml
<project basedir="." default="testreport" name="APIAutomation">
<property name="test.suite" value="FirstLoginTest"/>
<property name="soapui.project" value="C:/Users/F3020722/Desktop/Notification/New folder/APIRegression.xml"/>
<property name="soapui.home" value="C:/Program Files (x86)/SmartBear/SoapUI-5.0.0"/>
<property name="results.dir" value="C:/Users/F3020722/Desktop/Notification/API/Results"/>
<property name="reports.dir" value="${results.dir}/Reports"/>
<property name="html.dir" value="${reports.dir}/html"/>
<target name="execute.project">
<exec dir="${soapui.home}/bin" executable="testrunner.bat">
<arg line="-raj -f ${results.dir} -s ${test.suite} ${soapui.project}" />
</exec>
</target>
<target name="testreport" depends="execute.project">
<mkdir dir="${reports.dir}"/>
<junitreport todir="${reports.dir}">
<fileset dir="${results.dir}">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="${html.dir}" />
</junitreport>
</target>
</project>
You can also find a docker image for soapui and run tests & generate junit style html report as well. Refer soapui repository # hub.docker.com
Note: that build script used docker images is exactly the same as above except the machine path.

Code coverage results are not available in TeamCity

I am using TeamCity 7.1 with MsBuild build step running the following task:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="BuildTrunk" DependsOnTargets="Compile;Test" />
<Target Name="Compile">
<MSBuild Projects="Project.sln" Targets="Rebuild" Properties="Configuration=DEBUG" />
</Target>
<Target Name="Test">
<NUnitTeamCity Assemblies="#(TestAssemblies)" NUnitVersion="NUnit-2.5.10" />
</Target>
<ItemGroup>
<TestAssemblies Include="Project.Tests\bin\Debug\Project.Tests.dll" />
</ItemGroup>
</Project>
And I configured PartCover for this step (set path to PartCover 4.0.2 libraries, used proper XSLT files, also copied just in case PartCover.dll and renamed it to PartCover.CorDriver.dll), however once tests are executed code coverage results are not available and "Code Coverage" tab is not displayed in TeamCity. What is wrong with this configuration?

Ant build file cannot find mysql program

I'm learning Java and Eclipse on a Mac. I have an Ant build file in a project that contains sql statements to create a MySql database and tables and insert rows to set up data for the project. I have MySql set up correctly and can use the "mysql" command in terminal with no problem, but when I run the Ant build.xml file in Eclipse, I get: "BUILD FAILED. Cannot run program "mysql": error=2, No such file or directory"
I have done the following without success:
Added /usr/local/mysql/bin to my path and verified with "echo $PATH".
Added /usr/local/mysql/bin to my classpath in Eclipse through "properties" on the project.
Added build.xml to the build path in Eclipse (just for grins.)
I am running:
Mac OS X 10.7.1
Eclipse Indigo Build id: 20110615-0604
MySql 5.5.15-osx10.6-x86_64
Thanks for your help!
Here is my build.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project name="publisher" default="all" basedir=".">
<property name="mysql.params" value="-u publisher -ppublisher -D publisher" />
<target name="all" depends="cleandb, createdb, insertdb"></target>
<target name="cleandb">
<exec executable="mysql" input="cleandb.sql">
<arg line="${mysql.params}" />
</exec>
</target>
<target name="createdb">
<exec executable="mysql" input="createdb.sql">
<arg line="${mysql.params}" />
</exec>
</target>
<target name="insertdb">
<exec executable="mysql" input="insertdb.sql">
<arg line="${mysql.params}" />
</exec>
</target>
</project>
Does it work when you run the Ant build from the command line? If so, its probably the same problem described here:
Running ant through eclipse it doesn't find environment variables, but running ant through terminal is fine
Any reason not to just be using Ant's SQL task and Connector/J?
In any case, it sounds like you just haven't made sure that that /usr/local/mysql/bin is available on the PATH used when executing the Ant build. There's an Environment tab in the Ant build configuration that should allow you to modify the path for the environment Eclipse will run your Ant build file in.
There's a couple of things I would try:
Set the searchpath attribute to true (it is false by default):
<target name="cleandb">
<exec executable="mysql" input="cleandb.sql" searchpath="true">
<arg line="${mysql.params}" />
</exec>
</target>
Use a nested env element to set the path.
<property environment="env"/>
<exec ... >
<env key="PATH" path="${env.PATH}"/>
</exec>

IntelliJ generated ant builds with unit tests?

How can I take an IntelliJ generated ant build and incorporate my project's unit tests? I would like to incorporate Hudson into my development process.
Edit the build.xml to include the <junit> and <junitreport> tasks.
<target name="junit-test" description="run all junit tests" depends="compile">
<!-- Debug output
<property name="test.class.path" refid="test.class.path"/>
<echo message="${test.class.path}"/>
-->
<junit printsummary="yes" haltonfailure="${haltonfailure}">
<classpath refid="test.class.path"/>
<formatter type="xml"/>
<batchtest fork="yes" todir="${junit.out}">
<fileset dir="${test.src}">
<include name="**/*Test.java"/>
</fileset>
</batchtest>
</junit>
<junitreport todir="${junit.out}">
<fileset dir="${junit.out}">
<include name="TEST-*.xml"/>
</fileset>
<report todir="${junit.out}" format="frames"/>
</junitreport>
</target>