-
Notifications
You must be signed in to change notification settings - Fork 11
Ant
Selenified is designed to work seamlessly in your ant project, whether it is a new one, or existing one. Ensure you are using the standard ant project setup.
First thing to do is to add Selenified as a dependency. Update your ivy.xml
file to include (or add the dependency
block to your current dependencies).
<dependencies>
<dependency org="com.coveros" name="selenified" rev="3.1.0" />
</dependencies>
Alternatively, you can embed your dependency block in your build.xml
file, to avoid external dependencies. To do this, simply create a resolve
target, which the classpath will need to depend on.
<target name="resolve">
<ivy:retrieve pathid="classpath">
<dependency org="com.coveros" name="selenified" rev="3.1.0" />
</ivy:retrieve>
</target>
If following the setup indicated, you'll need to add a target to execute your tests. Update your build.xml file to include
<target name="selenified" depends="compile" description="Run integration tests in parallel">
<java classpathref="classpath" classname="org.testng.TestNG" failonerror="true">
<arg value="-testclass"/>
<arg value="SampleIT"/>
</java>
</target>
This assumes that a Java class called SampleIT.java
exists and contains your functional tests. Alternatively, you could specify a testng.xml
file which contains test packages, classes, or methods to run. Then from the command line run
ant selenified
If everything is set up properly, no runtime parameters are required, but many can be provided to change and optimize runtime performance. This can and should be done by configuring the selenified target. Several options exist to change how your tests are run.
Configuration | Description |
---|---|
threads |
how many tests you want to run in parallel |
verbosity |
how much logging is desired |
listener |
if you want to loop through multiple browsers for the same test, use the custom Selenified Transformer
|
groups |
what tests do you want to include or exclude in the test run based on the provided groups tagging |
files |
what tests do you want to include or exclude in the test run based on the test file names |
More options can he found here. It's best to set most of these configuration values up as parameters, so that they can be easily overridden from the command-line. You'll want to add these as options to the selenified
target.
<arg value="-parallel"/>
<arg value="methods"/>
<arg value="-threadcount"/>
<arg value="${threads}"/>
<arg value="-dataproviderthreadcount"/>
<arg value="${threads}"/>
<arg value="-verbose"/>
<arg value="${verbosity}"/>
<arg value="-listener"/>
<arg value="com.coveros.selenified.utilities.Transformer"/>
<arg value="-groups" if:set="groups.include"/>
<arg value="${groups.include}" if:set="groups.include"/>
<arg value="-excludegroups" if:set="groups.exclude"/>
<arg value="${groups.exclude}" if:set="groups.exclude"/>
<arg value="-testclass"/>
<arg value="[TESTCLASSES]"/>
Additionally, the system properties to override settings should also be added.
<sysproperty key="hub" value="${hub}" if:set="hub"/>
<sysproperty key="proxy" value="${proxy}" if:set="proxy"/>
<sysproperty key="appURL" value="${appURL}" if:set="appURL"/>
<sysproperty key="browser" value="${browser}" if:set="browser"/>
<sysproperty key="headless" value="${headless}" if:set="headless"/>
<sysproperty key="options" value="${options}" if:set="options"/>
<sysproperty key="defaultWait" value="${defaultWait}" if:set="defaultWait"/>
<sysproperty key="generatePDF" value="${generatePDF}" if:set="generatePDF"/>
<sysproperty key="packageResults" value="${packageResults}" if:set="packageResults"/>
Finally, ensure some of these values have default settings
<condition property="threads" else="5">
<isset property="threads"/>
</condition>
<condition property="verbosity" else="3">
<isset property="verbosity"/>
</condition>
To set these parameters from the command-line, you'll want to pass in the variable name preceded by a -D
and set the desired value. For example, to change threading from the default 5 to 2, the below command would be used:
ant selenified -Dthreads=2
<project xmlns:ivy="antlib:org.apache.ivy.ant" xmlns:if="ant:if" name="Selenified Ant Sample" basedir="." default="selenified">
<property name="rootdir" value="./"/>
<property name="lib-dir" value="./lib"/>
<property name="test-dir" value="./src"/>
<property name="out-dir" value="./target"/>
<property name="com-dir" value="${out-dir}/classes"/>
<condition property="threads" else="5">
<isset property="threads"/>
</condition>
<condition property="verbosity" else="3">
<isset property="verbosity"/>
</condition>
<path id="classpath">
<fileset dir="${lib-dir}" includes="**/*.jar"/>
<pathelement location="${lib-dir}"/>
<pathelement location="${com-dir}"/>
</path>
<target name="clean">
<delete dir="${out-dir}"/>
<delete dir="${lib-dir}"/>
</target>
<target name="resolve">
<ivy:retrieve pathid="classpath">
<dependency org="com.coveros" name="selenified" rev="3.1.0" />
</ivy:retrieve>
</target>
<target name="classpath" depends="resolve">
<path id="classpath">
<fileset dir="${lib-dir}" includes="**/*.jar"/>
<pathelement location="${com-dir}"/>
</path>
</target>
<target name="compile" depends="classpath">
<mkdir dir="${com-dir}"/>
<javac srcdir="${test-dir}" destdir="${com-dir}" classpathref="classpath" includeantruntime="false"/>
</target>
<target name="selenified" depends="compile">
<java classpathref="classpath" classname="org.testng.TestNG" failonerror="true">
<sysproperty key="hub" value="${hub}" if:set="hub"/>
<sysproperty key="proxy" value="${proxy}" if:set="proxy"/>
<sysproperty key="appURL" value="${appURL}" if:set="appURL"/>
<sysproperty key="browser" value="${browser}" if:set="browser"/>
<sysproperty key="headless" value="${headless}" if:set="headless"/>
<sysproperty key="options" value="${options}" if:set="options"/>
<sysproperty key="defaultWait" value="${defaultWait}" if:set="defaultWait"/>
<sysproperty key="generatePDF" value="${generatePDF}" if:set="generatePDF"/>
<sysproperty key="packageResults" value="${packageResults}" if:set="packageResults"/>
<arg value="-d"/>
<arg value="${out-dir}"/>
<arg value="-suitename"/>
<arg value="Selenified Ant Example"/>
<arg value="-parallel"/>
<arg value="methods"/>
<arg value="-threadcount"/>
<arg value="${threads}"/>
<arg value="-dataproviderthreadcount"/>
<arg value="${threads}"/>
<arg value="-verbose"/>
<arg value="${verbosity}"/>
<arg value="-listener"/>
<arg value="com.coveros.selenified.utilities.Transformer"/>
<arg value="-groups" if:set="groups.include"/>
<arg value="${groups.include}" if:set="groups.include"/>
<arg value="-excludegroups" if:set="groups.exclude"/>
<arg value="${groups.exclude}" if:set="groups.exclude"/>
<arg value="-testclass"/>
<arg value="ReadmeSampleIT"/>
</java>
</target>
</project>
A sample ant project can be found here
© Coveros 2019