Jenkins always show success - TestNG, Selenium - java

I'm new with Jenkins and I have a problem with builds. I'm writing UI tests with Selenium, Java and TestNG.
My problem is that Jenkins always shows Finished: SUCCESS even if some tests fail.
===============================================
TestAll
Total tests run: 10, Failures: 1, Skips: 0
===============================================
[SSH] exit-status: 0
TestNG Reports Processing: START
Looking for TestNG results report in workspace using pattern: **/testng-results.xml
Did not find any matching files.
Started calculate disk usage of build
Finished Calculation of disk usage of build in 0 seconds
Started calculate disk usage of workspace
Finished Calculation of disk usage of workspace in 0 seconds
Notifying upstream projects of job completion
No emails were triggered.
Finished: SUCCESS
How can I resolve my problem?

I assume you are building a Maven Project.
To stop a build on test failure, go to the configure part of your project then go to the build section and in "goals & options line" add :
-Dmaven.test.failure.ignore=false
this should stop the build if errors are found.

Related

How to print 'Configuration Failure' log on the console which occurs at #BeforeTest of TestNG test class?

I am running some 20 test classes during the regression test. There are some classes where I am getting the 'Configuration Failure' error. I am running my tests from the command line using maven commands. The thing is while going through the logs, I am not able to identify at which classes the mentioned error is coming. After the execution, I just get the info as :
===============================================
TestSuite
Total tests run: 124, Passes: 97, Failures: 8, Skips: 19
Configuration Failures: 2, Skips: 35
===============================================
But I want to print this error log on the console so that it will be easy for me to debug.
Any idea how can I achieve this?
You can see the detailed stacktrace at test-output. This folder generated by TestNG automatically.
Just open index.html by a browser.

why selenium test cases are got skipped randomly while running testng.xml in windows cmd

I have tried to run the selenium automation test cases using testng.xml file with multiple cases, but some cases got skipped. TestNG not showing skipped testcases count also, but showing total count and failures count. Can't find the reason and resolve this issue.
So i need solution for run the tescases using testng.xml without skipping in windows cmd using following command in cmd line;
java org.testng.TestNG %project_location%\sample_testng.xml
Could you please anyone help me on this issue ?
Your tests weren't skipped. They were successful.
Tests run: 19 = Total test count.
Failures: 15 = Failed tests.
Skips: 0 = Skipped tests.
Total test count - Failed tests - Skipped tests = Successful tests.
19 - 15 - 0 = 4 Successful tests

Jenkins-Maven build failed: Could not find the main class: jenkins.maven3.agent.Maven32Main. Program will exit

My Jenkins build is failing since a couple of days ago. When I compare the previous success build, I found that maven32-agent-1.8.1.jar updated to maven32-agent-1.12-alpha-1.jar similarly maven3-interceptor-commons-1.8.1.jar to maven3-interceptor-commons-1.12-alpha-1.jar.
JDK : JDK_6u45
Maven : 3.2.3
The error I get now is :
xx/var/lib/jenkins/tools/hudson.model.JDK/JDK_6u45/bin/java -XX:MaxPermSize=512m -cp /usr01/var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven32-agent-1.12-alpha-1.jar:/usr01/app/apache-maven-3.2.3/boot/plexus-classworlds-2.5.1.jar:/usr01/app/apache-maven-3.2.3/conf/logging jenkins.maven3.agent.Maven32Main /usr01/app/apache-maven-3.2.3 /var/cache/jenkins/war/WEB-INF/lib/remoting-3.14.jar /usr01/var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven32-interceptor-1.12-alpha-1.jar /usr01/var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.12-alpha-1.jar 85426
Could not find the main class: jenkins.maven3.agent.Maven32Main. Program will exit.
ERROR: Failed to launch Maven. Exit code = 1
Started calculate disk usage of build
Finished Calculation of disk usage of build in 0 seconds
Started calculate disk usage of workspace
Finished Calculation of disk usage of workspace in 0 seconds
Finished: FAILURE
Any solution for this?

Maven - testing stucks before the end on Windows 7

Building project on Win7 takes huge ammout of time, especially leaving the test suite. On my windows machine for 172 tests it takes 230 seconds, and on Jenkins (Ubuntu) about 19 seconds.
I run maven with -X argument to see what it is hanging on, but none of error appeard, after that time it just goes to run next plugin.
I tried to speed up it with setting surefire plugin to run on 4 threads, but it is not the case - Jenkins has exactly the same project as me.
I found that sometimes it hangs on calling externall processes, but the projects is not calling any externall processes (what would be even so easy according to run it on two different OS).
When I run the tests one by one in Win7 the working time is definitly lower that runing them with whole rebuild. This behaviour is the same on other Win7 machines.
How can I figure out what is keeping the maven from leaving the tests and going to next step?
Windows 7 output
Last test output
<--- stucks here
Tests run: 172, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 230.682 sec - in TestSuite
Results :
Tests run: 172, Failures: 0, Errors: 0, Skipped: 0
Next plugin run
Ubuntu output
Last test output
Tests run: 172, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 18.954 sec - in TestSuite
Results :
Tests run: 172, Failures: 0, Errors: 0, Skipped: 0
Next plugin run
Setting up the surefire plugin version to the latest one 2.19, from 2.16 helped. Now on Windows 7 it takes about 12 seconds, but still I have no idea what was the original cause of stucking.
In order to understand what is going on in your OS, you have to somehow debug your OS. I recommend taking a look at Microsoft Sysinternals and try to use Procmon (Process Monitor) and see what is going on. Sadly, it won't get you all the syscalls as strace on Linux does, but it might help you understand more what is going on.
You can also debug your JVM that executes the tests, it might also give you some answers.

How to analyze ant build output for further decision making?

I'm writing an ant build script to run regression tests for an application. I need to run the test cases sequentially and only if the previous test run was successful. Is there a way I can look a the output of the build to decide if the next target can be called?
[exec] [revBuild] RC = 1
[exec] -------------------------------------------------
[exec] Result: 1
BUILD SUCCESSFUL
Total time: 3 minutes 23 seconds
In the above output, the called application has failed. Is there a way I can search for the application return code in the build output, based on which the next ant target(to run the next test case) can be called?
You probably just want to set the failonerror attribute of the exec task to true. If you do this and the executable's return status code is anything other than 0, then the buildwill fail.
Youi could also store this status code in a property using the resultproperty attribute, and execute some task only if this property is set (or is not set).

Categories

Resources