Добрый день, коллеги!
Писал я тесты и использовал их самостоятельно запуская из IDE и жил не тужил. Но возникла потребность в постоянном автоматическом прогоне тестов. Почитал статейки, литературу и вооружившись ant'ом решил гонять их на jenkins'е
Настроил build.xml:
<?xml version="1.0" encoding="UTF-8"?> <project name="TestNGTesting.jar" basedir = "."> <!--======================================================================== Properties =========================================================================--> <property name="src.dir" location="${basedir}/src"/> <property name="bin.dir" value="${basedir}/bin"/> <property name="lib.dir" location="${basedir}/lib"/> <property name="build.dir" value="${basedir}/build"/> <property name="jar.name" value="TestNGTesting.jar"/> <property name="report.dir" value="${basedir}/report"/> <property name="TestNG.report.dir" value="${report.dir}/TestNGreport"/> <!--======================================================================== Classpath =========================================================================--> <path id="classpath"> <pathelement path="${classpath}"/> <pathelement location="${selenium.jars}/selenium-java-2.53.0.jar"/> <pathelement location="${selenium.jars}/selenium-server-standalone-2.53.0.jar"/> <pathelement location="${selenium.jars}/avalon-framework-4.1.4.jar"/> <pathelement location="${selenium.jars}/testng-6.8.7-sources.jar"/> <pathelement location="${selenium.jars}/testng-6.8.7.jar"/> <pathelement location="${ECLIPSE_HOME}plugins/org.testng.eclipse_6.9.11.201604020423/lib/testng.jar"/> <pathelement location="${ECLIPSE_HOME}plugins/org.testng.eclipse_6.9.11.201604020423/lib/jcommander.jar"/> <pathelement location="${ECLIPSE_HOME}plugins/org.testng.eclipse_6.9.11.201604020423/lib/bsh-2.0b4.jar"/> <pathelement location="${ECLIPSE_HOME}plugins/org.testng.eclipse_6.9.11.201604020423/lib/snakeyaml.jar"/> </path> <!--======================================================================== Creating folders =========================================================================--> <target name = "MakeDirs" description = "Making of the auxillary dirs"> <mkdir dir="${report.dir}"/> </target> <!--======================================================================== Compilation of the classes =========================================================================--> <target name = "compile" description = "Compilation of the classes"> <javac includeantruntime = "false" destdir="${bin.dir}" debug="off"> <src path="${src.dir}"/> <!--Откуда берем--> <classpath id="classpath"> <fileset dir="${lib.dir}"> <include name="selenium-java-2.53.0.jar"/> <include name="selenium-server-standalone-2.53.0.jar"/> <include name="avalon-framework-4.1.4.jar"/> <include name="testng-6.8.7-sources.jar"/> <include name="testng-6.8.7.jar"/> </fileset> </classpath> </javac> </target> <!--======================================================================== TESTING =========================================================================--> <taskdef resource="testngtasks" classpathref="classpath" /> <target name="run" description="Start tests" depends="compile"> <mkdir dir="${TestNG.report.dir}"/> <testng outputdir="${TestNG.report.dir}" classpathref="classpath" > <xmlfileset dir="${basedir}" includes="testng.xml"/> </testng> </target> </project>
Так как нет более опытных коллег под рукой, оценить правильность и оптимальность возможности не имею
Теперь к проблеме:
Вот на эту строку
<testng outputdir="${TestNG.report.dir}" classpathref="classpath" >
ругается так:
BUILD FAILED C:\workspace\test\build.xml:69: Problem: failed to create task or type testng Cause: The name is undefined. Action: Check the spelling. Action: Check that any custom tasks/types have been declared. Action: Check that any <presetdef>/<macrodef> declarations have taken place.
К сожалению, либо я не умею пользоваться поиском, либо описаний решения проблемы не так уж и много.
Прошу отнестись с пониманием, опыта в такой настройке не имею, только постигаю