1

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/Abc/testng.xml is not a valid file

Below are my POM and testng.xml files. Am I doing something wrong here? 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>
Prome
1,01511 silver badges25 bronze badges
asked Apr 19, 2020 at 16:19
1
  • <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE suite SYSTEM "testng.org/testng-1.0.dtd"> <suite name="FirstProject_Tstng"> <test thread-count="5" name="Test"> <classes> <class name="testng_demo.Inherit"/> <class name="testng_demo.NewTestcase"/> <class name="testng_demo.TestCase"/> </classes> </test> <!-- Test --> </suite> <!-- FirstProject_Tstng --> I'm getting an error in 2nd line <!DOCTYPE....> Can anyone help me ? Commented Jan 19, 2021 at 12:34

1 Answer 1

2

Try this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite">
 <test name= "TestCases">
 <classes>
<class name= "tests.CreateAssistTest"/> 
 </classes> 
 </test>
</suite> <!-- Suite -->

your testng.xml is wrong (https://testng.org/doc/documentation-main.html#testng-xml), Use a good IDE. It will show the exact error.

I tried your POM and it works fine:

enter image description here

answered Apr 19, 2020 at 16:59
7
  • Hi PDHide, thanks for your answer. I'm getting the same error with this xml you sent. I'm using eclipse ide and I'm able to launch the testng.xml successfully from there or through the comand line but from Jenkins I'm getting this error. Commented Apr 19, 2020 at 22:33
  • How are you triggering this in jenkins? Commented Apr 19, 2020 at 23:12
  • Through Maven Plugin Commented Apr 20, 2020 at 3:03
  • @Tester which jenkins version are you using , it works fine for me. I am triggering it as mvn test in a build batch file step. My jenkisn version is 2.222.1 . I used your POM only Commented Apr 20, 2020 at 13:03
  • I'm using version 2.204.2. How do you trigger it in a build batch file step? Thanks. Commented Apr 20, 2020 at 13:42

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.