ERROR: Publisher hudson.tasks.junit.JUnitResultArchiver aborted due to exception - jenkins

I have performed a Junit test successfully from eclipse.
So i wanted to execute the same test cases from Jenkins.
For that i have written the build.xml (ant build).
<path id="classpath">
<pathelement location="lib\junit-4.12-javadoc.jar" />
<pathelement location="lib\junit-4.12-sources.jar" />
<pathelement location="lib\junit-4.12.jar" />
<pathelement location="lib\ojdbc14.jar" />
<pathelement location="lib\oraclejdbc.jar" />
<pathelement location="lib\testng-6.8.5.jar" />
<pathelement location="bin" />
</path>
<target name="compile">
<javac classpath="classpath" includeantruntime="false" srcdir="./src" destdir="bin" includes="**/*.java" verbose="true">
</javac>
</target>
<target name="run_tests" depends="compile">
<junit printsummary="on" haltonfailure="false" showoutput="yes">
<formatter type="xml" usefile="false" />
<test name="om.wipro.TestDbUpdates" />
<test name="om.wipro.TestExample" />
<classpath>
<pathelement location="lib\junit-4.12-javadoc.jar" />
<pathelement location="lib\junit-4.12-sources.jar" />
<pathelement location="lib\junit-4.12.jar" />
<pathelement location="lib\ojdbc14.jar" />
<pathelement location="lib\oraclejdbc.jar" />
<pathelement location="lib\testng-6.8.5.jar" />
<pathelement location="bin" />
</classpath>
</junit>
</target>
My problem is that, the execution from Jenkins is not successful. Build is successful(from both eclipse and Jenkins) though test cases are failing.
How to get rid of the following error?
ERROR: Publisher hudson.tasks.junit.JUnitResultArchiver aborted due to exception
hudson.AbortException:
Regards,
Sharon M P

There is a ticket about this error:
https://issues.jenkins-ci.org/browse/JENKINS-24946
If you are using Jenkins version "V1.582", they recommend to upgrade to the latest version to solve this issue.
You can check your jenkins version at the bottom/right of the web page.

Related

Not able to execute testNG xml from ANT build.xml

I am using below build.xml to execute my testng xml. This build.xml is working fine for me when I required only Selenium standalone jar.
<project name="TestNGTest" default="test" basedir=".">
<!-- Define <testng> task -->
<taskdef name="testng" classname="org.testng.TestNGAntTask">
<classpath>
<pathelement location="SupportFiles/JarFiles/commons-cli-1.0.jar" />
<pathelement location="SupportFiles/JarFiles/commons-logging.jar" />
<pathelement location="SupportFiles/JarFiles/crimson.jar" />
<pathelement location="SupportFiles/JarFiles/hsqldb.jar" />
<pathelement location="SupportFiles/JarFiles/jaxp.jar" />
<pathelement location="SupportFiles/JarFiles/jconfig.jar" />
<pathelement location="SupportFiles/JarFiles/jmxri.jar" />
<pathelement location="SupportFiles/JarFiles/jxl.jar" />
<pathelement location="SupportFiles/JarFiles/mysql-connector-java-5.1.6-bin.jar" />
<pathelement location="SupportFiles/JarFiles/selenium-server-standalone-2.45.0.jar" />
<pathelement location="SupportFiles/JarFiles/xlSQL_Y8.jar" />
</classpath>
</taskdef>
<property name="testdir" location="bin" />
<property name="srcdir" location="src" />
<property name="libdir" location="SupportFiles" />
<property name="subdir" location="JarFiles" />
<property name="full-compile" value="true" />
<path id="classpath.base" />
<path id="classpath.test">
<!--pathelement location="${libdir}/testng-6.8.5.jar" /-->
<!--pathelement location="${subdir}/SeleniumTestNG.jar" /-->
<pathelement location="${subdir}/selenium-server-standalone-2.45.0.jar" />
<pathelement location="${subdir}/commons-cli-1.0.jar" />
<pathelement location="${subdir}/commons-logging.jar" />
<pathelement location="${subdir}/crimson.jar" />
<pathelement location="${subdir}/hsqldb.jar" />
<pathelement location="${subdir}/jaxp.jar" />
<pathelement location="${subdir}/jconfig.jar" />
<pathelement location="${subdir}/jmxri.jar" />
<pathelement location="${subdir}/jxl.jar" />
<pathelement location="${subdir}/mysql-connector-java-5.1.6-bin.jar" />
<pathelement location="${subdir}/xlSQL_Y8.jar" />
<!-- pathelement location="${libdir}/jxl-2.6.12.jar"/-->
<pathelement location="${testdir}" />
<fileset dir="${testdir}" includes="*.jar" />
<fileset dir="${libdir}">
<include name="**/*.jar" />
</fileset>
<pathelement location="${testdir}" />
<pathelement location="${srcdir}" />
<path refid="classpath.base" />
</path>
<target name="clean">
<delete verbose="${full-compile}">
<fileset dir="${testdir}" includes="**/*.class" />
</delete>
</target>
<target name="compile" depends="clean">
<javac srcdir="${srcdir}" destdir="${testdir}" verbose="${full-compile}" fork="yes" includeantruntime="false">
<classpath refid="classpath.test" />
</javac>
</target>
<target name="test" depends="compile">
<testng outputdir="C:\Users\A592013\.jenkins\jobs\Jenkins - Selenium\workspace\test-output" classpathref="classpath.test">
<xmlfileset dir="." includes="TestNG_Sanity.xml" />
</testng>
</target>
</project>
It is giving below message as BUILD SUCCESSFUL, however not executing the scripts. Below is the detail warning message:
[javac] C:\DurgeshProjectWork\Workspace\SeleniumWorkspace\DevOps_DIT\src\net\atos\selenium\common\XML.java:835: warning: OutputFormat is internal proprietary API and may be removed in a future release
[javac] OutputFormat format = new OutputFormat(document);
[javac] ^
[javac] C:\DurgeshProjectWork\Workspace\SeleniumWorkspace\DevOps_DIT\src\net\atos\selenium\common\XML.java:835: warning: OutputFormat is internal proprietary API and may be removed in a future release
[javac] OutputFormat format = new OutputFormat(document);
[javac]
Can anyone please tell what is wrong in my build.xml
Thanks a lit for your help on this. Just a FYI. I am reading excel data with the help of XLSQL 8 so required all these jars to execute this.
Thanks a lot for your help on this.
^

Creating Ant classpath out of project names

In an ant build script I have a list of projects we are depending on. I need to create a classpath for compilation.
I have:
included.projects=ProjectA, ProjectB
and I need:
included.project.classpath=../ProjectA/bin, ../ProjectB/bin
current code:
<echo message="${included.projects}" />
<pathconvert property="included.projects.classpath" dirsep="," >
<map from="" to="../"/>
<path location="${included.projects}"/>
</pathconvert>
<echo message="${included.projects.classpath}" />
<javac srcdir="${src.dir}" destdir="${build.dir}" includeantruntime="false" source="1.6">
<classpath>
<pathelement path="${classpath}" />
<dirset includes="${included.projects.classpath}" />
</classpath>
</javac>
I've tried it with explicit declaration too, but didn't work:
<path id="modules.classpath">
<fileset dir="../ModuleA/bin" />
<fileset dir="../ModuleB/bin"/>
</path>
<path id="libraries.classpath">
<fileset dir="lib" includes="*.jar"/>
</path>
<javac srcdir="${src.dir}" destdir="${build.dir}" includeantruntime="false" source="1.6">
<classpath refid="libraries.classpath" />
<classpath refid="modules.classpath" />
</javac>
I'm curious, what is the problem with explicit declaration code, and is it possible to solve with the comma-separated-string to classpath solution.
I think it would be simpler to explicity declare the classpath at the top of your build as follows:
<path id="compile.path">
<fileset dir="../ProjectA/bin" includes="*.jar"/>
<fileset dir="../ProjectB/bin" includes="*.jar"/>
</path>
Used as follows:
<javac srcdir="${src.dir}" destdir="${build.dir}" includeantruntime="false" source="1.6">
<classpath>
<path refid="compile.path"/>
<pathelement path="${classpath}" />
</classpath>
</javac>
Note:
I read your question again and just realised that you're not using jar files built by the other projects, are you? .... Not a great idea....

Groovy-TestNG-Ant running error

I've faced with next problem.
Trying to create pilot test-project using Groovy, TestNG, ant.
If I run tests from my IDE (Eclipse) - all is ok.
But when I try run tests using ant - not easy for me problem. Could you help me?
build.xml is present below.
Compile target - pass ok, but on runTest target I see problem:
"Exception in thread "main" java.lang.NoClassDefFoundError: groovy/lang/GroovyObject"
<project basedir="." default="runTest" name="Ant file for TestNG">
<property name="src" location="src" />
<property name="build" location="build" />
<property name="libs" location="lib" />
<path id="class.path">
<pathelement location="${libs}/testng.jar" />
<pathelement location="lib/testng.jar"/>
<pathelement location="${build}" />
</path>
<taskdef name="testng" classname="org.testng.TestNGAntTask">
<classpath>
<pathelement location="lib/groovy-all.jar"/>
<pathelement location="lib/testng.jar"/>
</classpath>
</taskdef>
<target name="runTest" depends="compile">
<mkdir dir="testng_output"/><!-- Create the output directory. -->
<testng outputdir="testng_output" classpathref="class.path">
<xmlfileset dir="." includes="testng.xml"/>
</testng>
</target>
<target name="compile">
<delete dir="build"/>
<mkdir dir="build"/>
<taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc" classpath="lib/groovy-all.jar"/>
<groovyc srcdir="src" destdir="./build">
<classpath>
<pathelement path="lib/groovy-all.jar"/>
<pathelement path="lib/testng.jar"/>
</classpath>
<javac source="1.7" target="1.7" debug="off" />
</groovyc>
</target>
</project>
And this is testng.xml
<suite name="My Test Suite" parallel="methods" thread-count="5">
<test name="My Test">
<classes>
<class name="test1" />
</classes>
</test>
</suite>

how do I use client certitificate file for svnkit in ant?

My svn admin require us to install a pfx client cert file on our windows machine to connect. I tried that and have no problem connecting to svn with TortoiseSVN.
Now I need to write an ant script and use svnkit inside to checkout/update. How do I specify the client file?
<java classname="org.tmatesoft.svn.cli.SVN" dir="src" fork="true">
<arg value="co" />
<arg value="--username" />
<arg value="xxxxx" />
<arg value="--password" />
<arg value="xxxx" />
<arg
value="https://123.456.789.123/xxx/xxx" />
<classpath>
<pathelement location="lib/antlr-runtime-3.4.jar" />
<pathelement location="lib/jna-3.4.0.jar" />
<pathelement location="lib/sequence-library-1.0.2.jar" />
<pathelement location="lib/sqljet-1.1.3.jar" />
<pathelement location="lib/svnkit-javahl16-1.7.5.jar" />
<pathelement location="lib/trilead-ssh2-1.0.0-build215.jar" />
<pathelement location="lib/svnkit-1.7.5.jar" />
<pathelement location="lib/svnkit-cli-1.7.5.jar" />
</classpath>
</java>
I don't know what a "pfx client cert file" is, but I'm assuming you're talking about a Java truststore?
Try adding the standard ssl properties to the Java program as follows:
<java classname="org.tmatesoft.svn.cli.SVN" dir="src" fork="true">
<sysproperty key="javax.net.ssl.keyStore" value="client.keystore" />
<sysproperty key="javax.net.ssl.keyStorePassword" value="123456" />
<sysproperty key="javax.net.ssl.trustStore" value="client.truststore" />
<sysproperty key="javax.net.ssl.trustStorePassword" value="123456" />
..
Reference:
JSSE Reference Guide

How do I generate Emma code coverage reports using Ant?

How do I setup an Ant task to generate Emma code coverage reports?
To answer questions about where the source and instrumented directories are (these can be switched to whatever your standard directory structure is):
<property file="build.properties" />
<property name="source" location="src/main/java" />
<property name="test.source" location="src/test/java" />
<property name="target.dir" location="target" />
<property name="target" location="${target.dir}/classes" />
<property name="test.target" location="${target.dir}/test-classes" />
<property name="instr.target" location="${target.dir}/instr-classes" />
Classpaths:
<path id="compile.classpath">
<fileset dir="lib/main">
<include name="*.jar" />
</fileset>
</path>
<path id="test.compile.classpath">
<path refid="compile.classpath" />
<pathelement location="lib/test/junit-4.6.jar" />
<pathelement location="${target}" />
</path>
<path id="junit.classpath">
<path refid="test.compile.classpath" />
<pathelement location="${test.target}" />
</path>
First you need to setup where Ant can find the Emma libraries:
<path id="emma.lib" >
<pathelement location="${emma.dir}/emma.jar" />
<pathelement location="${emma.dir}/emma_ant.jar" />
</path>
Then import the task:
<taskdef resource="emma_ant.properties" classpathref="emma.lib" />
Then instrument the code:
<target name="coverage.instrumentation">
<mkdir dir="${instr.target}"/>
<mkdir dir="${coverage}"/>
<emma>
<instr instrpath="${target}" destdir="${instr.target}" metadatafile="${coverage}/metadata.emma" mode="copy">
<filter excludes="*Test*"/>
</instr>
</emma>
<!-- Update the that will run the instrumented code -->
<path id="test.classpath">
<pathelement location="${instr.target}"/>
<path refid="junit.classpath"/>
<pathelement location="${emma.dir}/emma.jar"/>
</path>
</target>
Then run a target with the proper VM arguments like:
<jvmarg value="-Demma.coverage.out.file=${coverage}/coverage.emma" />
<jvmarg value="-Demma.coverage.out.merge=true" />
Finally generate your report:
<target name="coverage.report" depends="coverage.instrumentation">
<emma>
<report sourcepath="${source}" depth="method">
<fileset dir="${coverage}" >
<include name="*.emma" />
</fileset>
<html outfile="${coverage}/coverage.html" />
</report>
</emma>
</target>
The User Guide has a good example of how to set up your build script so that you not only seperate the instrumented code from the execution, but it's also all contained in the same <target> so that you don't have to run a series of different targets, but instead you can just do something like ant emma tests (if ant tests was how you normally ran your unit tests, for example).
Here's their example:
<target name="emma" description="turns on EMMA instrumentation/reporting" >
<property name="emma.enabled" value="true" />
<!-- EMMA instr class output directory: -->
<property name="out.instr.dir" value="${basedir}/outinstr" />
<mkdir dir="${out.instr.dir}" />
</target>
<target name="run" depends="init, compile" description="runs the examples" >
<emma enabled="${emma.enabled}" >
<instr instrpathref="run.classpath"
destdir="${out.instr.dir}"
metadatafile="${coverage.dir}/metadata.emma"
merge="true"
/>
</emma>
<!-- note from matt b: you could just as easily have a <junit> task here! -->
<java classname="Main" fork="true" >
<classpath>
<pathelement location="${out.instr.dir}" />
<path refid="run.classpath" />
<path refid="emma.lib" />
</classpath>
<jvmarg value="-Demma.coverage.out.file=${coverage.dir}/coverage.emma" />
<jvmarg value="-Demma.coverage.out.merge=true" />
</java>
<emma enabled="${emma.enabled}" >
<report sourcepath="${src.dir}" >
<fileset dir="${coverage.dir}" >
<include name="*.emma" />
</fileset>
<txt outfile="${coverage.dir}/coverage.txt" />
<html outfile="${coverage.dir}/coverage.html" />
</report>
</emma>
</target>
Emma 2.1 introduces another way of obtaining runtime coverage information (.ec file). One can remotely request the data from the given port of the computer where an instrumented application is runnig. So there's no need to stop VM.
To get the file with runtime coverage data you need to insert the following snippet in your Ant script between running of your tests and generating coverage report:
<emma>
<ctl connect="${emma.rt.host}:${emma.rt.port}" >
<command name="coverage.get" args="${emma.ec.file}" />
<command name="coverage.reset" />
</ctl>
</emma>
Other steps are similar to Emma 2.0. They are perfectly described in previous post
More information on Emma 2.1 features: http://sourceforge.net/project/shownotes.php?group_id=108932&release_id=336859

Resources