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.
^
Related
I'm having a problem where the CSS isn't compiled at all. Ant seems to work as expected, nothing happens with my CSS files though.
Can anyone help figure out why my CSS isn't compiling?
Here's the output from running ant -v
$ ant -v
Apache Ant(TM) version 1.8.2 compiled on December 3 2011
Trying the default build file: build.xml
Buildfile: /var/www/testsite/build.xml
Detected Java version: 1.6 in: /usr/lib/jvm/java-6-openjdk-amd64/jre
Detected OS: Linux
parsing buildfile /var/www/testsite/build.xml with URI = file:/var/www/testsite/build.xml
Project base dir set to: /var/www/testsite/www
parsing buildfile jar:file:/usr/share/ant/lib/ant.jar!/org/apache/tools/ant/antlib.xml with URI = jar:file:/usr/share/ant/lib/ant.jar!/org/apache/tools/ant/antlib.xml from a zip file
Override ignored for property "TODAY"
[property] Loading /var/www/testsite/www/build.properties
BUILD SUCCESSFUL
Total time: 0 seconds
graeme#ubuntu:/var/www/testsite$ ant -v
Apache Ant(TM) version 1.8.2 compiled on December 3 2011
Trying the default build file: build.xml
Buildfile: /var/www/testsite/build.xml
Detected Java version: 1.6 in: /usr/lib/jvm/java-6-openjdk-amd64/jre
Detected OS: Linux
parsing buildfile /var/www/testsite/build.xml with URI = file:/var/www/testsite/build.xml
Project base dir set to: /var/www/testsite/www
parsing buildfile jar:file:/usr/share/ant/lib/ant.jar!/org/apache/tools/ant/antlib.xml with URI = jar:file:/usr/share/ant/lib/ant.jar!/org/apache/tools/ant/antlib.xml from a zip file
Override ignored for property "TODAY"
[property] Loading /var/www/testsite/www/build.properties
BUILD SUCCESSFUL
Total time: 0 seconds
Here's my build.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<project name="testsite.co.uk" basedir="./www">
<tstamp>
<format property="TODAY" pattern="yyyy-M-dd-hh-mm" locale="en,UK"/>
</tstamp>
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath>
<pathelement location="/usr/share/java/ant-contrib.jar"/>
</classpath>
</taskdef>
<property
name="yui-compressor.jar"
location="/home/testsite/Downloads/yui-ant/lib/yuicompressor-2.4.2.jar" />
<property
name="yui-compressor-ant-task.jar"
location="/home/testsite/Downloads/yui-ant/bin/yui-compressor-ant-task-0.5.1.jar" />
<path id="task.classpath">
<pathelement location="${yui-compressor.jar}" />
<pathelement location="${yui-compressor-ant-task.jar}" />
<pathelement location="/home/testsite/Downloads/yui-ant/lib/rhino-js-1.6r7.jar" />
<pathelement location="/home/testsite/Downloads/znerd-optipng-ant-task-ff33669/build/optipng-ant-task.jar" />
</path>
<taskdef
name="yui-compressor"
classname="net.noha.tools.ant.yuicompressor.tasks.YuiCompressorTask">
<classpath refid="task.classpath" />
</taskdef>
<taskdef name="optipng" classname="com.pensioenpage.jynx.optipng.OptiPNGTask" classpath="/home/testsite/Downloads/znerd-optipng-ant-task-ff33669/build/optipng-ant-task.jar" />
<property file="build.properties" />
<target name="export">
<tar destfile="./exported_latest_update_${TODAY} ${TSTAMP}.tar"
basedir="./"
includes = "www/**"
excludes=".git/**, .gitignore/**, www/secure/images/categories/**, www/secure/images/content/**, www/secure/images/products/**, www/secure/images/widgets/**">
<date datetime="08/14/2009 10:00 AM" when="after"/>
</tar>
</target>
<target name="css-frontend">
<property name="cssFilePath" value="./www/css"/>
<property name="cssUrlPath" value="/css"/>
<property name="frontendCss" value="build.frontend"/>
<delete>
<fileset dir="./www/css" includes="build.frontend.*.css" />
</delete>
<concat destfile="${cssFilePath}/${frontendCss}.css">
<fileset dir="./www/css" includes="reset.css" />
<fileset dir="./www/css" includes="text.css" />
<!--<fileset dir="./www/css" includes="forms.css" />-->
<fileset dir="./www/css" includes="tables.css" />
<fileset dir="./www/css" includes="vendor-logos.css" />
<fileset dir="./www/lib/javascript/fancybox2/" includes="jquery.fancybox.css" />
<!--<fileset dir="./www/css" includes="wp-panel.css" />-->
<fileset dir="./www/lib/javascript/jQuery.mmenu-master/dist/css" includes="jquery.mmenu.custom.css" />
<fileset dir="./www/css" includes="styles-2015.css" />
<fileset dir="./www/css" includes="loop54-styles.css" />
<fileset dir="./www/css" includes="feature_icons.css" />
<fileset dir="./www/css" includes="shopzilla.override.css" />
<fileset dir="./www/css/responsive-2015" includes="below-1100.css" />
<fileset dir="./www/css/responsive-2015" includes="below-1024.css" />
<fileset dir="./www/css/responsive-2015" includes="below-980.css" />
<fileset dir="./www/css/responsive-2015" includes="above-980.css" />
<fileset dir="./www/css/responsive-2015" includes="below-690.css" />
<fileset dir="./www/css/responsive-2015" includes="below-500.css" />
<fileset dir="./www/css/responsive-2015" includes="below-320.css" />
<fileset dir="./www/css/responsive-2015" includes="retina-screens.css" />
</concat>
<concat destfile="${cssFilePath}/build.wp-style.css">
<fileset dir="./www/css" includes="reset.css" />
<fileset dir="./www/css" includes="text.css" />
<fileset dir="./www/css" includes="vendor-logos.css" />
<fileset dir="./www/css" includes="wp-style.css" />
</concat>
<concat destfile="${cssFilePath}/build.checkout.css">
<fileset dir="./www/lib/javascript/fancybox2/" includes="jquery.fancybox.css" />
<fileset dir="./www/css" includes="reset.css" />
<fileset dir="./www/css" includes="text.css" />
<fileset dir="./www/css" includes="forms.css" />
<fileset dir="./www/css" includes="tables.css" />
<!--<fileset dir="./www/css" includes="wp-panel.css" />-->
<fileset dir="./www/css" includes="one-page-checkout.css" />
</concat>
<checksum file="${cssFilePath}/${frontendCss}.css" property="css_md5"/>
<property name="frontendCssMd5" value="build.frontend"/>
<move file="${cssFilePath}/${frontendCss}.css" tofile="${cssFilePath}/${frontendCssMd5}.css"/>
<yui-compressor
warn="false"
munge="true"
preserveallsemicolons="false"
fromdir="${cssFilePath}"
todir="${cssFilePath}/">
<include name="${frontendCssMd5}.css" />
<include name="build.wp-style.css" />
<include name="build.checkout.css" />
<include name="720plus.css" />
<include name="719minus.css" />
</yui-compressor>
</target>
</project>
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.
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>
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
I have an ant script that I am trying to run my junit test from. It runs all but the junit portion of the ant with no errors. Anyone know why it's not hitting this portion of my script?
<?xml version="1.0"?>
<property file="build.properties" />
<property name="test.class.name" value="edu.psu.ist.probability.TestProbability" />
<path id="test.classpath">
<pathelement location="${classes}" />
<pathelement location="/lib/junit.jar" />
<fileset dir="${lib}">
<include name="**/*.jar"/>
</fileset>
</path>
<taskdef resource="checkstyletask.properties" classpath="${checkstyle}" />
<taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask">
<classpath>
<pathelement path="${findbugs.jar}" />
</classpath>
</taskdef>
<!--
Encapsulates the process of starting up program.
-->
<target name="run" depends="build">
<echo>-----------RUN-----------</echo>
<java classname="${main}" fork="true">
<!-- fork needed for running on OS X -->
<classpath>
<pathelement location="${jar}" />
<fileset dir="lib">
<include name="**/*.jar" />
</fileset>
</classpath>
</java>
</target>
<!--
Encapsulates the process of packaging (jarring) program.
-->
<target name="build" depends="document">
<echo>---------BUILD--------</echo>
<jar destfile="${jar}" basedir="${classes}" />
</target>
<!--
Encapsulates the process of generating javadoc for program.
-->
<target name="document" depends="findbugs">
<echo>-------DOC--------</echo>
<javadoc sourcepath="${src}" defaultexcludes="yes" destdir="${docs}" executable="C:\Program Files (x86)\Java\jdk1.6.0_20\bin\javadoc.exe" author="true" version="true" use="true" windowtitle="Decisions API">
</javadoc>
</target>
<!--
Encapsulates the process of executing findbugs against program.
-->
<target name="findbugs" depends="style">
<echo>----------FINDBUGS----------</echo>
<findbugs home="${findbugs}" output="html" outputFile="${findbugs.output}" failOnError="true" stylesheet="fancy.xsl">
<auxClasspath>
<fileset dir="${lib}">
<include name="**/*.jar" />
</fileset>
</auxClasspath>
<sourcePath path="${src}"/>
<class location="${classes}" />
</findbugs>
</target>
<!--
Encapsulates the process of style-checking program.
-->
<target name="style" depends="compile">
<echo>---STYLE---</echo>
<checkstyle config="${checkstyleconfig}" classpath="${classes}">
<fileset dir="${src}" includes="**/*.java"
excludes="**/DecisionsProgram.java, **/*Test.java" />
</checkstyle>
</target>
<!--
Encapsulates the process of compiling program.
-->
<target name="compile" depends="clean">
<echo>------------COMPILE--------</echo>
<javac destdir="${classes}">
<src path="${src}" />
<classpath>
<fileset dir="lib">
<include name="**/*.jar" />
</fileset>
</classpath>
</javac>
</target>
<!--
Encapsulates the process of cleaning up program directory structure.
-->
<target name="clean">
<!-- make sure dirs exist first, to prevent error -->
<mkdir dir="${classes}" />
<mkdir dir="${dist}" />
<mkdir dir="${docs}" />
<mkdir dir="${reports}" />
<!-- now delete them -->
<delete dir="${classes}" />
<delete dir="${dist}" />
<delete dir="${docs}" />
<delete dir="${reports}" />
<!-- now recreate them so they can be used -->
<mkdir dir="${classes}" />
<mkdir dir="${dist}" />
<mkdir dir="${docs}" />
<mkdir dir="${reports}" />
</target>
<target name="test" depends="compile">
<echo>-------JUNIT----------</echo>
<junit fork="yes" haltonfailure="yes">
<test name="${test.class.name}" />
<formatter type="plain" usefile="false" />
<classpath refid="test.classpath" />
</junit>
</target>
There is no target which is invoking "test".
One possibility is to replace
<target name="style" depends="compile">
with
<target name="style" depends="test">