Executing testcases from jenkins and getting error - jenkins

We have automated few test cases and trying to execute the same test cases from jenkins and getting below error:
+ pybot -x junit.xml run.robot
==============================================================================
Run
==============================================================================
sip-001 | PASS |
------------------------------------------------------------------------------
sip-002 | PASS |
------------------------------------------------------------------------------
Run | PASS |
2 critical tests, 2 passed, 0 failed
2 tests total, 2 passed, 0 failed
Output: /opt/bitnami/apps/jenkins/jenkins_home/jobs/integration-test/workspace/output.xml
[ ERROR ] Reading XML source '/opt/bitnami/apps/jenkins/jenkins_home/jobs/integration-test/workspace/output.xml' failed: ImportError: No module named expat; use SimpleXMLTreeBuilder instead
Here Testcases are passed but results junit.xml are not generating.
The same testcases if we execute from Ubuntu machine. /path/run.robot .
The Testcases are passed and results are generating like junit.xml, output.xml etc..
Manually testcases are executing fine and results are generating.
Can anyone please guide me in resolving the above error which we got while executing from Jenkins.

You can use https://wiki.jenkins-ci.org/display/JENKINS/Robot+Framework+Plugin robotframework plugin to display results in Jenkins.

WORKAROUND: This won't help you keep using Jenkins, but I had a similar issue with Test Cases running fine when I executed them manually from the command prompt on Windows or running Robot Framework in Eclipse. When running in Jenkins I got failures and never was able to get an answer from anyone, anywhere. I finally just dumped Jenkins all together and set up a Windows Task Manager to have the Robot Framework test case run from there instead. I'll continue using that until someone gets me a real fix or answer that I can actually implement. By the way: Thanks for the negative! Keep them coming.

Related

Passing Thread Properties in Taurus YAML JMeter

I am trying to build a Taurus yaml file for the below Jmeter scenarios, I have 2 threads where I am passing the Number Of Threads and Duration. Now with the regular command line, I use the below command to start the script, I use this same command from Jenkins too. This works fine and generate reports but not blazemeter one, so i am trying Taurus integration...
nohup /ssd/jmeter/apache-jmeter-5.3/bin/jmeter3g -Jquoteoff.threads=20 -Jquote.threads=20 -n -t /ssd/jmeter/scripts/PerformanceTesting/src/PS/OFFLINE_ONLINE.jmx
My below YML give me error, i am not sure if i am missing anything.
execution:
- scenario:
properties:
quote.threads: 20
quoteoff.threads: 20
onduration: 3600
script: /ssd/jmeter/scripts/PerformanceTesting/src/PS/OFFLINE_ONLINE.jmx
Also is there any direct command like shell we can use to invoke this script? I have seen a few places directly calling JMX script in Jenkins but not sure how to pass parameters in that scenarios.
I have no clue what's wrong here but below line is what causing the failure when i am trying to run bzt script.jmx
log.debug( vars.get("QUOTE_ID"));
To fix it when I changed log.debug to log.info it fixed the below problem I was facing. This is the partial answer as i am not sure about the reason for failure, but this should solve an issue where the script runs fine in Jmeter but bzt gives an error for XML parsing.
Wouldn't that be easier to add BlazeMeter Uploader plugin to your JMeter test plan, the plugin can be installed using JMeter Plugins Manager
It's possible to run existing .jmx script without creating any YAML
bzt /path/to/your/test.jmx
The correct syntax to define properties is:
execution:
- scenario: simple
scenarios:
simple:
script: tests/jmx/dummy.jmx
properties:
quote.threads: 20
#etc
Parameters can be passed via -o command-line argumententer link description here

Not showing Code Coverage on SonarQube Dashboard when I pass output(xml file) generated by nunit3-console

I run testcases on Jenkins using nunit3-console.exe. Some test Cases fails but nunit-result.xml is generated.
When testcases fails Jenkins job is exited with error code -2. So I put a EXIT 0 which continue the Jenkins jobs, I a still getting nunit output file that is nunit-result.xml.
Then I pass this xml file to sonar-scanner so that I can see code Coverage on SonarQube Dashboard.
Everything work fine. Jenkins job is Successful. But I can't see Code Coverage on SonarQube DashBoard.
Command to generate output file (nunit-result.xml) :
(path)\\nunit3-console.exe (path)\\Test.Common.dll --result=(path)nunit-result.xml;format=nunit2
"Test.commom.dll" is Test case File.
"nunit-result.xml is output file generated.
Before It was giving error that <test-result> element not found then I put "format=nunit2" which gave me right output.
After this I run this code:-
(path)\\sonar-scanner
-Dsonar.projectKey=${projectKey}
-Dsonar.projectName=${projectKey}
-Dsonar.organization=organization
-Dsonar.host.url=http://sonar.(server-path).com
-Dsonar.login=username
-Dsonar.password=pasword
-Dsonar.sourceEncoding=UTF-8
-Dsonar.sources=.
-Dsonar.projectVersion=1.0
-Dsonar.cs.nunit.reportsPaths=(path)\\nunit-result.xml
-Dsonar.exclusions=**/bin/**,**/obj/**,**/node_modules/**,**/*.spec.ts"
I should see Code Coverage on SonarQube Dashboard after this. But I see all other things except Code Coverage.
P.S. : Is used "(path)" for just example I am replacing it with proper file path ?

NUnit3 with SpecFlow runs in VS and as batch command but not in Jenkins

I have my selenium tests written using SpecFlow(+SpecRun) and NUnit framework (v.3.8.1.0). I've configured Jenkins to run these tests. My Jenkins Windows Batch Command is as follows:
"C:\Program Files (x86)\NUnit.ConsoleRunner\3.7.0\tools\nunit3-console.exe"
C:\Projects\Selenium\ClassLibrary1\PortalTests\bin\Debug\PortalTests.dll
--test=TransactionTabTest;result="%WORKSPACE%\TestResults\TestR.xml";format=nunit3
When I trigger build test seems to start running as I'm getting as far as end of NUNIT3-CONSOLE [inputfiles] [options] with spinner indicating that test is running but it actually never ends and estimated remaining time is: N/A.
Now, when I run this script with windows cmd.exe:
"[PATH to Console.exe]\nunit3-console.exe" PortalTests.dll -- test=TransactionTabTest
this test pass successfully and so does in VS.
Now, I know this is very generic question but any clues will be much appreciated.
As you are using SpecFlow+Runner/Specrun, you can find the documentation how to configure it for the different build servers here: http://specflow.org/plus/documentation/SpecFlowPlus-and-Build-Servers/

Gtest does not write result xml file on test failure [jenkins]

I invoke our gtest suite for iOS in Jenkins using the shell script
#!/bin/sh
pkill -a "iPhone Simulator"
ios-sim launch ${WORKSPACE}/source/apple/build/Debug-iphonesimulator/MyAppTest.app --args --gtest_output=xml:${WORKSPACE}/JUnitTestResultsIOS.xml
exit $?
This always successfully runs the tests, and when the tests pass the xml file gets generated as expected. However, when the tests fail, no xml file is generated, and the "Execute shell command" build step terminates but does not fail the job. I echoed the exit code and it comes back 0 even when the tests fail.
This is even more confusing to me since we have a basically identical script in the same job for running tests on our OSX version. This always writes the xml and successfully fails the job when the tests fail.
This behavior seems totally arbitrary and everything about our configuration seems to be exactly as it should be. What am I missing?
Thanks!
There were two things at work here.
First of all, we had the break_on_failure gtest option enabled, which works great when running tests on a local machine but isn't useful within Jenkins, so we disabled it on the build machine.
The second issue was around how we used the exit code. Since ios-sim launch ... always succeeds we were always getting an exit code of 0, regardless of whether the tests passed or failed. I ended up using grep to determine if the resulting xml file indicated any failures, and generated an exit code based on that.

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.

Resources