Page tree
Skip to end of metadata
Go to start of metadata

Last updated: Jul 02, 2020 10:28

Ivy is a tool for managing project dependencies, including recording, tracking, resolving, and reporting aspects of a project. This section walks you through setting up an Ivy project with Perfecto.

A sample project is available on GitHub:

Watch this video to see a demo of the integration setup. Detailed steps follow.

On this page:

1 | Get started

In this step, you install Java and Ant.

To get started:

  1. Download and install JDK 8.
  2. Set up the JAVA_HOME environment variable to point to the JDK 8 installation folder.
  3. Install Apache Ant.
  4. Download and install the IvyDE Eclipse plugin.
  5. Launch a command line window and run the following command to verify that the installation was successful:

    ant -version

2 | Create and configure a project

In this step, you create a Java project and add the repositories and dependencies using Ivy and the plugins required to run it with Perfecto.

To create and configure a project:

  1. In your IDE, create a Java project.
  2. In the project's root folder, create a build.xml file and update it as follows. A sample build.xml file that includes all required properties and ant targets is available here.

     Click to view sample code
    <project name="PerfectoIvySample" xmlns:ivy="antlib:org.apache.ivy.ant">
    	<property environment="env"/>
    	<!-- some variables used -->
    	<property name="basedir" value="." />
    	<property name="lib.dir" value="lib" />
    	<property name="build.dir" value="build" />
    	<property name="bin.dir" value="bin" />
    	<property name="src.dir" value="src" />
    	<property file="" />
    	<property name="report-dir" value="${basedir}/Test-Report" />
    	<property name="testng-report-dir" value="${report-dir}/TestNGreport" />
    	<property name="target" value="1.8" />
    	<property name="source" value="1.8" />
    	<property name="testNGXmlFile" value="testng_Selenium.xml"></property>
    	<!-- paths used for compilation and run  -->
    	<path id="build.classPath">
    		<pathelement location="${bin.dir}" />
    		<fileset dir="${lib.dir}">
    			<include name="*.jar" />
    			<include name="**/*.jar" />
    	<path id="">
    		<path refid="build.classPath" />
    		<path location="${build.dir}" />
    	<target name="clean">
    	        <delete dir="{bin.dir}"/>
    	<target name="bootstrap" description="Used to install the ivy task jar" depends="clean">
    <!--	    <mkdir dir="${ant.home}/lib"/>
    -->	    <get dest="${ant.home}/lib/ivy.jar" src=""/>
    	<!-- =================================
    	          target: resolve
    	         ================================= -->
    		<target name="resolve" description="--> retreive dependencies with ivy" depends="bootstrap">
    			<ivy:resolve />
    		<!-- Compile the java code from ${src} into ${bin} -->
    		<target name="compile" depends="resolve">
    			<javac srcdir="${src.dir}" classpathref="build.classPath" includeAntRuntime="No" destdir="${bin.dir}" />
    			<echo> /* Compiled Directory Classes */ </echo>
    		<target name="testng-execution" depends="compile">
    			<taskdef name="testng" classname="org.testng.TestNGAntTask" classpathref="build.classPath"/>
    			<mkdir dir="${testng-report-dir}" />
    			<testng outputdir="${testng-report-dir}" classpathref="build.classPath" useDefaultListeners="true">
    				<jvmarg value="-DcloudName=${cloudName}"/>
    				<jvmarg value="-DsecurityToken=${securityToken}"/>
    				<jvmarg value="-Dreportium-job-name=${reportium-job-name}"/>
    				<jvmarg value="-Dreportium-job-number=${reportium-job-number}"/>
    				<xmlfileset dir="${basedir}" includes="${testNGXmlFile}" />
    			<!-- Runs the file and generates Reportng report for TestNG-->
  3. In the project's root folder, create an ivy.xml file and add the below dependencies. A sample file is located here.

     Click to view sample code
    <ivy-module version="2.0">
        <info organisation="org.perfecto.sample" module="PerfectoIvySample"/>
            <dependency org="io.appium" name="java-client" rev="6.1.0"/>
            <dependency org="org.seleniumhq.selenium" name="selenium-support" rev="3.141.59"/>
            <dependency org="org.seleniumhq.selenium" name="selenium-api" rev="3.141.59"/>
            <dependency org="org.testng" name="testng" rev="7.1.0"/>
            <dependency org="com.perfecto.reporting-sdk" name="reportium-java" rev="2.2.9"/>
            <dependency org="com.perfectomobile" name="pm-webdriver" rev=""/>
            <dependency org="com.perfectomobile" name="http-client" rev=""/>
            <dependency org="" name="guava" rev="25.0-jre"/>
  4. In the project's root folder, create an ivysettings.xml file and add the following repositories. A sample file is located here.

     Click to view sample code
    <?xml version="1.0" encoding="ISO-8859-1"?>
    	<settings defaultResolver="chain" />
    		<chain name="chain">
    			<ibiblio name="central" m2compatible="true" />
    			<ibiblio name="Perfecto mobile" m2compatible="true" root="" />
  5. To download all dependencies, run the target with an Ivy resolve task (resolve).

3 | Execute TestNG tests

In this step, you run the tests. Optionally, you can also integrate with Perfecto Smart Reporting.

To execute TestNG tests: 

  1. Run the build.xml with the following Ant targets and properties:

    If credentials are hardcoded
    If credentials are passed as parameters
    testng-execution -DcloudName=${cloudName} -DsecurityToken=${securityToken} -DtestNGXmlFile=testng_Perfecto.xml

    Ant automatically kick-starts the execution of testng_Selenium.xml. If you want to run mobile tests, provide -DtestngXmlFile=testng_Perfecto.xml as Ant properties.

  2. To perform CI dashboard integration, supply the following properties to top-level Ant targets or the Ivy module configuration:


CI Dashboard integration

To integrate Ivy with Perfecto Smart Reporting, contact the Perfecto Professional Services team.

The following images show the PerfectoIvySample job in the CI Dashboard view and the sample Perfecto mobile web test report in the Report Library.