Cucumber JVM with Jenkin build some test cases stops in between - jenkins

I am facing very weird issue. I am running cucumber jvm for java project on Jenkin with fork count 10.
I have more than 100 features files. Sometimes some features files (not specific) stop their execution without giving any error or exception. So because of that their json files is not getting created and records also get missed in the cucumber html report. Like it is not consistent it occurs 1 out of 8 times. But it is not giving any exceptions, warning or error so hard to track. Any one know what is issue and can help me with this issue.?
Thanks.

Please split your execution, sometimes JVM getting peak. if our TCs running for long time, this will break our jenkins. so run your test by 20 to 30 features at a time.
like
max 30 features / one jenkins build
for Eg: if you have 100 features with 500 scebarios
Build 1 - mvn test -DCucumber.Options="--tags #first0to20"
Build 2 - mvn test -DCucumber.Options="--tags #first21to40"
Build 3 - mvn test -DCucumber.Options="--tags #first41to60"
Build 4 - mvn test -DCucumber.Options="--tags #first61to80"
Build 5 - mvn test -DCucumber.Options="--tags #first81to100"

Related

How to display code coverage for business layer in SonarQube Dashboard

I am new to Jenkins and SonarQube configuration. Wanted to display the code coverage of PCs layer of the project in SonarQube Dashboard. (Test cases are written using MS test framework)
Facing a problem as SonarQube Dashboard is showing 0% coverage inspite of having 40 + test cases for PCs layer.
Following are the ‘Build’ configuration:
Part 2:
SonarQube Dashboard
Assuming the probable cause – the sonarqube dashboard showing results of WebProject(as highlighted in screenshot) and not for the business layer. Need help in showing coverage of Business Layer of the Project(PCs as highlighted in screenshot)
You have 24k lines of code and 40 unit tests? The coverage percentage likely comes in at <1%... less than .5% even. So that's being rounded to 0%.
If you want to narrow it down, you can set exclusions for the stuff you don't want included in the coverage calculation (you'll have to re-analyze after making the updates for them to take effect) but you'll still likely weigh in around 0% until you add more tests.
This after months I was able to resolve. As the requirement was to achieve code coverage for Business layers like PC's as highlighted in above question. This was fixed by following the below steps:
Sonar plugin order should be:
Execute Windows batch command - to delete the .trx or .coveragexml files
SonarQube Scanner for MSBUILD - Begin Analysis
Build a VS project or solution using MSBUILD
Run Unit test with VSTest.console
Execute windows batch command- to convert the test report from trx to coveragexml
SonarQube Scanner for MSBUILD -End Analysis
Note: Make sure to Run Unit test with VSTest.console and not with MS Test
Change the path in windows batch command plugin to delete the test result file
d:\jenkins\tools\nuget\nuget.exe restore "%WORKSPACE%\<Project>.sln"
if exist TestResults\ del TestResults\*.trx
if exist TestResults\ del TestResults\*.coveragexml
Changed the path of the unit test dll to - "Bin\.UnitTest.dll".

Jenkins + Sonar project numbers in sonar is nerver reduce

Hi guys when I use Jenkins+Maven+Sonar
I found that when I delete a project in sonar and then I run the job in Jenkins
the total project number in sonar is never reduced . It just repeated increment .
Even I deleted the database and run again the number of project in sonar cant be reduced.
Is there some cache in sonar?
How can I reset the number of project?
This is likely caused by a corrupted Elasticsearch index. Shut down your server, delete $SONARQUBE_HOME/data and restart.

Using cobertura's line coverage for CUSTOM test code in a maven build

I have a some 'custom code' that runs during the maven project build. I would like to use cobertura's line coverage feature to generate report of the executed lines of my 'custom code' for a build.
What I have achieved so far:
I am using the maven cobertura plugin to generate the report.
The execution of 'custom code' is bound to the test phase of maven build.
The maven goal cobertura:cobertura runs cobertura:instrumentation first and then in the test phase my 'custom code' is executed.
The unexpected behavior:
Although, I expected the cobertura reports to show line coverage, the line coverage reports shows just 0.
Further investigating the issue I found that the cobertura:instrumentation takes place in a separate vm. Following a snapshot of the processes that are listed by 'ps' command.
6647 ? S 0:00 /bin/sh -c /home/user/softwares/JDK/jdk1.7.0_79/jre/bin/java -Dlog4j.configuration=file:/tmp/log4j628942363594701372config.properties -Xmx64m net.sourceforge.cobertura.instrument.InstrumentMain --commandsfile /tmp/cobertura.5724213382380101768.cmdline
6649 ? D 0:00 /bin/sh -c /home/user/softwares/JDK/jdk1.7.0_79/jre/bin/java -Dlog4j.configuration=file:/tmp/log4j628942363594701372config.properties -Xmx64m net.sourceforge.cobertura.instrument.InstrumentMain --commandsfile /tmp/cobertura.5724213382380101768.cmdline
Attempts at solving this:
In order to resolve this, I've tried to find how jmockit achieves the same. Haven't really been able to figure that out yet.
I have also tried attaching the execution code to the already running VM.
com.sun.tools.attach.VirtualMachine.attach(arg0);
Can somebody please help me out here.
Update - 23th October 2015
As per an excerpt from Cobertura Github Wiki,
java -cp C:\cobertura\lib\cobertura.jar;C:\MyProject\build\instrumented;C:\MyProject\build\classes;C:\MyProject\build\test-classes -Dnet.sourceforge.cobertura.datafile=C:\MyProject\build\cobertura.ser ASimpleTestCase
This should run the tests with the cobertura's instrumented code. I tried this with an extra -javaagent:agent.jar. This doesn't seem to work either.

Can't launch libgdx ios/robovm build in IPhone simulator with gradle

I'm trying to get a basic Hello World libgdx application running on the IPhone Simulator using gradle. I am new to gradle and robovm.
First I should note that I am able to successfully build and run tis example app https://github.com/jtakakura/robovm-sample-ios-app with the command:
./gradlew build launchIPhoneSimulator
Just as a small diversion, I am curious to know why
./gradlew launchIPhoneSimulator
fails. Apparently 'build' needs to be explicit.
wintermute:robovm-sample-ios-app matt$ ./gradlew launchIPhoneSimulator
:launchIPhoneSimulator
Classpath entry /Users/matt/code/robovm-sample-ios-app/build/classes/main does not exist
:launchIPhoneSimulator FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':launchIPhoneSimulator'.
> Main class org.robovm.sample.ios.RoboVMSampleIOSApp not found
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 7.115 secs
I would have thought that the launchIPhoneSimulator task would depend on the build task and that calling lanuchIPhoneSimulator would implicitly invoke build. Is this a mistake in the gradle-robovm-plugin (https://github.com/jtakakura/gradle-robovm-plugin) or is there something I am missing about gradle?
Ok, sorry back to my main question:
I generated a libgdx project using the command line tool supplied by Gdx-setup (https://github.com/libgdx/libgdx/tree/master/extensions/gdx-setup) with the arguments:
--dir /Users/matt/code/test --name test --package com.foo.bar --mainClass FooTest
I threw the generated project up on github so you can clone it with less hassle:
git clone https://github.com/mattwalters/libgdx-test libgdx-test
Then I'll run
./gradlew build
to build all the sub projects. But I am unable to get the ios build running on the simulator via
./gradlew launchIPhoneSimulator
I get a similar error to the one above:
wintermute:test matt$ ./gradlew ios:launchIPhoneSimulator
:ios:launchIPhoneSimulator
Classpath entry /Users/matt/code/test/ios/build/classes/main does not exist
:ios:launchIPhoneSimulator FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':ios:launchIPhoneSimulator'.
> Main class com.foo.bar.IOSLauncher not found
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 12.759 secs
I double checked that there is no typo between the actual name of the main class and the mainClass declared to gradle. And there is indeed no classes directory in ios/build, but I am not sure why.
Can anyone help shed some light on this for me? Thanks very much in advance.
Update 2014-01-24: At least one other user has verified that it now works, so please make sure you try again if you are still having problems.
Update 2014-01-23: I've recently checked in some bugfixes to the libgdx gradle support which has been merged into the daily builds. Assuming you use the daylies they should appear within 24 hours. At my end the new bugfixes makes "./gradlew ios:assemble launchIPhoneSimulator" work out of the box after creating a new project with the GdxSetup class.
Original response below:
First, make sure you use at least version 0.0.2 of the gradle-robovm-plugin. Secondly, try to build the sample project using the plugin from here:
https://github.com/jtakakura/robovm-sample-ios-app
The author of the plugin was kind enough to make this based on my request. I've tested the plugin with the example and it works without a hitch. It was discussed and resolved in a closed issue here:
https://github.com/jtakakura/gradle-robovm-plugin/issues/3
It's also worth noting that on recent libgdx builds, the command line tool for generating libgdx application templates already uses the plugin so you should be ready to go without the need to download and/or muck with the stuff yourself (short of getting libdx and running the command line util for generating a template project).
If you already have a project that you need to adapt, look carefully at the build.gradle file in the robovm-sample-ios-app example from the author of the example. It shows you what is needed to get a robovm build going.
Try to check is roboVMVersion and robovm-gradle-plugin in your main build.gradle points to latest robovm/plugin versions. If no - try to use latest. This helps me several times.

Robotium Tests not running on Jenkins but local

i try to integrate my Robotium Tests on our Jenkins Server. I implemented an android Test Project that based on our app Project. Everything works like a charm when i run the Tests on my local Machine on Windows out of Eclipse and also by calling from shell by call
'adb shell am instrument -w <our-package>/android.test.InstrumentationTestRunner'
So far, so good, but after i set up a build Job in Jenkins, let the Projects build by maven clean install sign etc. none of my tests will be proceeded. I also tried to call 'adb shell am instrument -w <our-package>/android.test.InstrumentationTestRunner' as shell command after the build step but also no result. The build ended up with just 2 Tests shown log below
[workspace] $ /bin/sh -xe /tmp/hudson3571502822112946903.sh
+ /home/jenkins/tools/android-sdk-linux/platform-tools/adb shell pm list instrumentation
instrumentation:com.android.emulator.connectivity.test/android.test.InstrumentationTestRunner (target=com.android.emulator.connectivity.test)
instrumentation:com.android.emulator.gps.test/android.test.InstrumentationTestRunner (target=com.android.emulator.gps.test)
instrumentation:com.zeppelin.zemos.test.addispo/android.test.InstrumentationTestRunner (target=com.zeppelin.zemos.addispo)
+ /home/jenkins/tools/android-sdk-linux/platform-tools/adb shell am instrument -w com.zeppelin.zemos.test.addispo/android.test.InstrumentationTestRunner
android.test.AndroidTestCase:.
android.test.LoaderTestCase:.
Test results for InstrumentationTestRunner=..
Time: 0.031
OK (2 tests)
Just the 2 Tests AndroidTestCase and LoaderTestCase are shown up and it seems that all of my other Testcases (i've implemented 11) are not processed by Jenkins.
I spent a long time googling around but found no solution for this. Could this be a ant Problem? I have Version 1.8 local and 1.6 on the Jenkins Server. Or is there another Problem i cannot see.....
Thanks a lot
You can try uninstalling the package from device/ emulator, using
"adb uninstall your_package"
Then, do a clean debug install again and then run the tests.

Resources