1

I have a Maven project and I'm using TestNG. My build completes in Jenkins, but the tests I want to run from my testng.xml file are not actually executed. I have my console output from Jenkins and my pom.xml file. Hopefully, something can be gleaned from this. The tutorials I've followed all seem to do something a little different with config settings or plug-ins. I meticulously followed one tutorial but somewhere I've done not something correctly. I would be hugely indebted for any assistance.

Started by user Jim Bradley
Running as SYSTEM
Building in workspace C:\Users\Jim\.jenkins\workspace\JimSeleniumTraining
Parsing POMs
Established TCP socket on 51971
[JimSeleniumTraining] $ java -cp C:\Users\Jim\.jenkins\plugins\maven-plugin\WEB-INF\lib\maven35-agent-1.13.jar;C:\Users\Jim\.jenkins\tools\hudson.tasks.Maven_MavenInstallation\MavenTest\boot\plexus-classworlds-2.6.0.jar;C:\Users\Jim\.jenkins\tools\hudson.tasks.Maven_MavenInstallation\MavenTest/conf/logging jenkins.maven3.agent.Maven35Main C:\Users\Jim\.jenkins\tools\hudson.tasks.Maven_MavenInstallation\MavenTest C:\Users\Jim\.jenkins\war\WEB-INF\lib\remoting-4.3.jar C:\Users\Jim\.jenkins\plugins\maven-plugin\WEB-INF\lib\maven35-interceptor-1.13.jar C:\Users\Jim\.jenkins\plugins\maven-plugin\WEB-INF\lib\maven3-interceptor-commons-1.13.jar 51971
<===[JENKINS REMOTING CAPACITY]===>channel started
Executing Maven:  -B -f C:\Users\Jim\.jenkins\workspace\JimSeleniumTraining\pom.xml clean install
[INFO] Scanning for projects...
[INFO] 
[INFO] -----------< SeleniumJavaFramework:SeleniumJavaFramework >------------
[INFO] Building SeleniumJavaFramework 0.0.1-SNAPSHOT
[INFO] -------------------------------[ jar ]--------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ SeleniumJavaFramework ---
[INFO] Deleting C:\Users\Jim\.jenkins\workspace\JimSeleniumTraining\target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ SeleniumJavaFramework ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\Jim\.jenkins\workspace\JimSeleniumTraining\src\main\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ SeleniumJavaFramework ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ SeleniumJavaFramework ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\Jim\.jenkins\workspace\JimSeleniumTraining\src\test\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ SeleniumJavaFramework ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ SeleniumJavaFramework ---
[INFO] No tests to run.
[JENKINS] Recording test results
[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ SeleniumJavaFramework ---
[WARNING] JAR will be empty - no content was marked for inclusion!
[INFO] Building jar: C:\Users\Jim\.jenkins\workspace\JimSeleniumTraining\target\SeleniumJavaFramework-0.0.1-SNAPSHOT.jar
[INFO] 
[INFO] --- maven-install-plugin:2.4:install (default-install) @ SeleniumJavaFramework ---
[INFO] Installing C:\Users\Jim\.jenkins\workspace\JimSeleniumTraining\target\SeleniumJavaFramework-0.0.1-SNAPSHOT.jar to C:\Users\Jim\.m2\repository\SeleniumJavaFramework\SeleniumJavaFramework\0.0.1-SNAPSHOT\SeleniumJavaFramework-0.0.1-SNAPSHOT.jar
[INFO] Installing C:\Users\Jim\.jenkins\workspace\JimSeleniumTraining\pom.xml to C:\Users\Jim\.m2\repository\SeleniumJavaFramework\SeleniumJavaFramework\0.0.1-SNAPSHOT\SeleniumJavaFramework-0.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  30.556 s
[INFO] Finished at: 2020-06-07T10:56:32-05:00
[INFO] ------------------------------------------------------------------------
Waiting for Jenkins to finish collecting data
[JENKINS] Archiving C:\Users\Jim\.jenkins\workspace\JimSeleniumTraining\pom.xml to SeleniumJavaFramework/SeleniumJavaFramework/0.0.1-SNAPSHOT/SeleniumJavaFramework-0.0.1-SNAPSHOT.pom
[JENKINS] Archiving C:\Users\Jim\.jenkins\workspace\JimSeleniumTraining\target\SeleniumJavaFramework-0.0.1-SNAPSHOT.jar to SeleniumJavaFramework/SeleniumJavaFramework/0.0.1-SNAPSHOT/SeleniumJavaFramework-0.0.1-SNAPSHOT.jar
channel stopped
[htmlpublisher] Archiving HTML reports...
[htmlpublisher] Archiving at PROJECT level C:\Users\Jim\.jenkins\workspace\JimSeleniumTraining to C:\Users\Jim\.jenkins\jobs\JimSeleniumTraining\htmlreports\Extent_20HTML_20Report
TestNG Reports Processing: START
Looking for TestNG results report in workspace using pattern: **/testng-results.xml
Did not find any matching files.
Finished: SUCCESS

http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0

    <groupId>SeleniumJavaFramework</groupId>
    <artifactId>SeleniumJavaFramework</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>SeleniumJavaFramework</name>
    <url>http://maven.apache.org</url>

UTF-8 1.6 1.6

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

org.seleniumhq.selenium selenium-java 3.141.59

<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.13</version>
    <scope>test</scope>
</dependency>

<dependency>
    <groupId>io.github.bonigarcia</groupId>
    <artifactId>webdrivermanager</artifactId>
    <version>3.8.1</version>
</dependency>

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

com.relevantcodes extentreports 2.41.2

    <!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
    <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>2.6</version>
    </dependency>

    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi</artifactId>
        <version>3.16-beta2</version>
    </dependency>


    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml</artifactId>
        <version>3.9</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml-schemas</artifactId>
        <version>3.9</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-scratchpad</artifactId>
        <version>3.9</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>ooxml-schemas</artifactId>
        <version>1.1</version>
    </dependency>

    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>openxml4j</artifactId>
        <version>1.0-beta</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi</artifactId>
        <version>3.9</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml</artifactId>
        <version>3.9</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml-schemas</artifactId>
        <version>3.9</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-scratchpad</artifactId>
        <version>3.9</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>ooxml-schemas</artifactId>
        <version>1.1</version>
    </dependency>

    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>openxml4j</artifactId>
        <version>1.0-beta</version>
    </dependency>

Project Structure

  • 1
    Your log is saying that maven failed to detect your tests source code so that it didn't even compile them. It also reports that you do not have a resource folder JimSeleniumTraining\src\test\resources for tests. So that no idea where is it assumed to take your testng.xml from. So two question here: 1 - have you tried to execute your tests with mvn locally? 2 - Can you share your project structure? – Alexey R. Jun 8 at 8:58
  • Thanks for your reply. I can execute my tests in Eclipse right from the testng.xml file. The results show up in my Extent Report as expected. What's the best way to show my project structure? A screen shot? In Eclipse, my testng.xml file is under a project node SeleniumJavaFramework\scr\test\resources. JimSeleniumTraining is the item name I gave in Jenkins. So, that might be an issue is seems. – Jim Bradley Jun 8 at 16:45
  • I think it will be okay if you make a screen shot of your folders say up to the second level from root.. If it does not take much space.. So you haven't try to run mvn test locally, right? – Alexey R. Jun 8 at 16:57
  • My inclination to the question of running mvn test locally is to say no. I've only right-clicked the testng.xml file and run my tests as TestNG Suite. I haven't done any execution by means of command line etc. – Jim Bradley Jun 8 at 17:25
1

First of all, before using anything in Jenkins it is better to debug your solution using command line since calling a command line is what Jenkins essentially does.

What I can see from your configs is that you hold your testng.xml in src/main/resources so I would start from fixing your sure-fire settings. Try to amend them so that they are:

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>3.0.0-M3</version>
        <configuration>
            <suiteXmlFiles>
                <suiteXmlFile>src/main/resources/testng.xml</suiteXmlFile>
            </suiteXmlFiles>
        </configuration>
    </plugin>

However, the best practice is to keep everything related to tests in src/test so I would move your testng.xml to src/test/resources

| improve this answer | |
  • I certainly appreciate the feedback Alexey. I'll do these recommendations. – Jim Bradley Jun 8 at 17:50
-1

Previous answer:

It looks like it might be related to your Jenkins environment setup.

Try this google forum, it might help you out in your problem.

[Edited: to clarify the my answer]

I assumed that you already have successfully build it in your local since you are deploying it already in your Jenkins and your question is also targeting Jenkins.

[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ SeleniumJavaFramework ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\Jim\.jenkins\workspace\JimSeleniumTraining\src\test\resources

Based on the error given that the existing resrouceDirectory is not found which indicates it cannot the find path where your test is. Since Maven is more on convention over configuration, the maven-surefire-plugin will look for testcases usually under src/test/java as far as I know. But since you specify that the test that you made is under resources. I will assumed again that you had already added the same as below to build your resources folder.

<testResources>
    <testResource>
        <directory>src/test/resources</directory>
        <filtering>true</filtering>
    </testResource>
</testResources>

As far as my link is concern although it talks about reports not being fetch with Jenkins but the problem is the same. Not able to fetch or run anything because of incorrect path in Jenkins setup. Like example, in that link it stated that:

Found the required option to change the default workspace in my Jenkins project.So I've added the path "$HOME/myWorkspace/myProject/" in my Jenkins project workspace and "**/target/surefire-reports/testng-results.xml" in my TestNG setting, and it works

As I said earlier, it is for displaying the result, but you can try looking into your workspace directory if it is correct or else your configuration might be wrong.

Side Note: I'm sorry, I'm pretty new in here, didn't know you need to have it like that.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.