Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Info
titlePlease note

There is a more up-to-date tutorial using Selenium providing additional capabilities. Please check it instead.

Overview

In this tutorial, we will create a Java Test class with multiple Test Cases, implemented in Java.

...

Code Block
titlesrc/test/resources/META-INF/services/org.testng.ITestNGListener
com.xpanditxpand.testng.annotations.XrayListener


XrayListener class is responsible for processing "Xray" annotation, get the values of some specific attributes and them as attributes to the ITestResult object.

...

Code Block
languagexml
titlepom.xml
collapsetrue
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.xpand.java</groupId>
    <artifactId>xpand-test</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        
        <!--XRay Properties -->
 
        <!--IN PROFILE ~.m2/settings.xml-->
        <!--<xray.jiraURL></xray.jiraURL>
        <xray.resultsFormat>JUNIT</xray.resultsFormat>
        <xray.username>admin</xray.username>
        <xray.password>123qwe</xray.password>-->
 
        <xray.projectKey>CALC</xray.projectKey>
        <!--
        <xray.testExecKey></xray.testExecKey>
        <xray.testPlanKey></xray.testPlanKey>
        <xray.testEnvironments></xray.testEnvironments>
        <xray.revision></xray.revision>
        -->
 
        <xray.surefire.location>${basedir}/target/surefire-reports</xray.surefire.location>
        <!--End Xray Properties -->
 
    </properties>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <debug>true</debug>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            
            <plugin>

                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version> 2<version>2.20.1</version>

                <configuration>
                    <testFailureIgnore>true</testFailureIgnore>

                    <suiteXmlFiles>
                      <suiteXmlFile>testng.xml</suiteXmlFile>
                    </suiteXmlFiles>

                    <properties>
                        <property>
                            <name>reporter</name>
                            <value>org.testng.reporters.XMLReporter:generateTestResultAttributes=true,generateGroupsAttribute=true</value>
                        </property>
                    </properties>

                </configuration>
             </plugin>




        </plugins>
    </build>

    <dependencies>
        <dependency>
          <groupId>org.testng</groupId>
          <artifactId>testng</artifactId>
          <version>7.4.0</version>
          <scope>test</scope>
        </dependency>

        <dependency>
                <groupId>com.xpandit.xray</groupId>
                <artifactId>xray-maven-plugin</artifactId>
                <version>1.0.0</version>
            	<scope>test</scope>
	    </dependency>
    </dependencies>

    <repositories>
           	<repository>
          		<id>xpandit</id>
       		<name>xpand-releases</name>
    		<url>http://maven.xpand-it.com/artifactory/releases</url>
    		<releases>
    			<enabled>true</enabled>
    		</releases>
    	</repository>
    </repositories>


    <reporting>
        <plugins>
            <plugin>
                <artifactId>maven-surefire-report-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>com.xpandit.xray</groupId>
                <artifactId>xray-maven-plugin</artifactId>
                <version>1.01.0</version>
            </plugin>
        </plugins>
    </reporting>
 

</project>

...