0
votes

I'm getting the following error when trying to run a Selenium/TestNg test from Jenkins.

[ERROR] Suite file /development/apps/config/jenkins/jobs/teste-automatizado/workspace/Juvo/testng.xml is not a valid file

Below are my POM and testng.xml files. I’m able to launch the testng.xml successfully from eclipse and comand line but from Jenkins I get this error.

Any help? Thanks in advance.

pom.xml:

<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>br.com.aoki</groupId>
  <artifactId>Juvo</artifactId>
  <version>0.0.1-SNAPSHOT</version>

  <properties>
        <project.build.sourceEncoding>ISO-8859-1</project.build.sourceEncoding>
  </properties>

  <build>
  <plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.1</version>
        <configuration>
            <source>1.7</source>
            <target>1.7</target>
            <encoding>ISO-8859-1</encoding>
        </configuration>

    </plugin>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>3.0.0-M4</version>
        <configuration>
            <suiteXmlFiles>
                <suiteXmlFile>testng.xml</suiteXmlFile>
            </suiteXmlFiles>
        </configuration>        
    </plugin>   
  </plugins>
  </build>

  <dependencies>

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.141.59</version>
    </dependency>

    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.14.3</version>
    </dependency>

    <dependency>
        <groupId>joda-time</groupId>
        <artifactId>joda-time</artifactId>
        <version>2.10.4</version>
    </dependency>

    <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>2.5</version>
    </dependency>

    <dependency>
        <groupId>com.oracle.ojdbc</groupId>
        <artifactId>ojdbc8</artifactId>
        <version>19.3.0.0</version>
    </dependency>

  </dependencies>

</project>

testng.xml

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite name="Suite">
  <test name="Test">
    <classes>
      <class name="tests.TestCreateAssistTest"/>
    </classes>
  </test>
</suite>
1

1 Answers

1
votes

This problem was reported in the stackoverflow already. I guess your file testng.xml appears in src/test/resources. The error says

Suite file /development/apps/config/jenkins/jobs/teste-automatizado/workspace/Juvo/testng.xml is not a valid file

It does not say Juvo/src/test/resources/testng.xml.

Obviously it cannot, because you placed the file in src/test/resources but the configuration says that the file is read at the root:

<suiteXmlFile>testng.xml</suiteXmlFile>

You have to rewrite the config with

<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>

because it has to match the real location of the file.

In Maven the paths are use to be relative to the project root.