Jasmine CI and Capturing Test Result Output on Jenkins Server - ruby-on-rails

Background:
Have inherited a Ruby on Rails 3.1.x project which is in need of some BDD and testing for Javascript code. So following the Instructions I have added the jasmine gem for JS testing. This works ok via rake jasmine and gives me the local web-server accessible via http://some-host.com:8888/
Problem:
What I want to do is use the tests on the CI server, which is running Jenkins. The Jenkins project is setup with the command rake jasmine:ci to run the CI variant of Jasmine. The output on the Jenkins build console log is below:
Waiting for jasmine server on 32901...
jasmine server started.
Waiting for suite to finish in browser ...
................
Finished in 0.00454 seconds
16 examples, 0 failures
* Stopping Xvfb :66.0 Xvfb
...done.
I'd like to capture the output; as in the view that is generated from the Jasmine web server page and preserve this with the build run. I've tried the obvious of seeing if there is an -o <filename.out> option, but not had any success.
Does anyone know how to capture the output in the context of running in a CI instance ? Does it require PhantomJS ?

I use phantomjs in combination with a junit compatible xml reporter for jasmine. Then I simply use the JUnit Jenkins plugin.
The junit reporter and glue code can be found here:
https://github.com/larrymyers/jasmine-reporters
This github project by Larry Myers has a good example setup for this. It contains a rhino and a phantomjs setup. I have only tried the phantomjs part and I am really pleased.

Related

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/

Jenkins + CasperJS

I have a series of frontend tests written in CasperJS that I need to run in Jenkins. Here is command I run from the command line: casperjs test ./src/tests/**/ts_*.js --xunit=xunit.xml. This runs the tests and saves the xunit file. Ok. When I have Jenkins run the same command it gets through loading the first test page and spits out this error: "Process leaked file descriptors" and directs me to: https://wiki.jenkins-ci.org/display/JENKINS/Spawning+processes+from+build
It provides an explanation and a few OS specific work arounds. The environment this will be run on will eventually be linux however my development environment is Windows and I don't understand the workaround they provide. What kind of file is that and how does it fit with Jenkins?
Does anyone have experience running CasperJS tests using Jenkins?
I installed jenkins as a service and use default settings.
I solved same issue on windows.
if you are running as a service and default home directory ( c:/program files(x86)/jenkins/ )
you have to change path to other normal folder(ex.c:/jenkins/").
SET JENKINS_HOME=c:\jenkins\
What I do with jenkins and casper:
I create a job with string parameter 'tests', which takes *.js or specified test
and try to run casper tests via Build -> Execute shell
cd ~/test_directory
casperjs test ${tests}

How to get jenkins to run my qunit test using phantomjs

Im working on getting our CI (Jenkins) to use and run our qunit test, we have qunit-reporter, qunit.compposite and phantomjs to execute the whole. Im not ant expert so im using windows batch command as a prestep with the following command
phantomjs src\test\webapp\js\runner.js src\test\webapp\jquery.all.test.html > test-report.xml
Now this runs and generates the junit xml file, with a few issues, firstly since I use pipe phantomjs performance information is also put into the file so that's my first issue
My second issue is that I have no idea in the world how I can get Jenkins to actually read the xml file instead of just considering it random stuff, similar to it interpreting when we have junit test run.
Just for reference the project is a maven project.
All advice is welcome :)
In Jenkins, configure your job, add a post build action, select publish JUnit test result report then add the path to your xml file in the requested field.
A couple years ago, a colleague of mine and I worked on getting PhantomJS to run QUnit tests and output JUnit XML that Jenkins can consume:
http://www.cameronjtinker.com/post/2013/09/24/QUnit-JSCoverage-and-Jenkins.aspx
I had forgotten to post this on my blog after we worked on this so I just posted it today when I saw your question. Much has changed since 2011 when this was originally written, but it should have most of the same concepts involved.

How would you run jasmine tests on a CI environment *without nodejs*

I have a bunch of jasmine tests that I would like to run on a jenkins CI server.
At the moment, we use an html page that runs the specs, that a developper can open in a browser on its own machine.
The transition to CI would be easy if I had access to some kind of server side test runner (like karma), however for some undisclosable reasons, I can not run nodejs on our CI server.
So in the spirit of creativity-under-constraints, what could I use to automate jasmine tests without node ? (But anything that can run with maven and a jdk is probably fine...)
You can make your test automatically spawn a browser with the page that runs your unit test. The tricky part tough is to get the result back to the main test runner. The solution that I have found for that is to use a custom jasmine reporter (you just need to implement the same function has to other reporter) and when a spec has finished to run you do an AJAX call to write that result in a file. The main runner just needs to wait until something is written in that file to see the results. Once the test are finish, just don't forget to kill the browser, otherwise your CI server will be flooded by window.

gradle tests hang for spring security tests with embedded ldap server

I have a set of tests for spring-security 3.1.3 with embedded ldap server that runs properly from eclipse or when run through gradle with -Dtest.single option. However when i do a clean build to run the entire set of tests in the project the execution hangs at the point where it hits those tests, at which point i have to kill the gradle process. If I #Ignore the ldap tests other tests work fine. These tests work properly if i dont use embedded server i.e connect to an external server. Probably something to do with fact that gradle executes tests in multi-threaded way and it tries to host an in-memory server and all that.
Any body faced similar issues ? and how might i get more useful info on what might be going on ? --info or --debug on gradle doesn't help and the test reports (like the ones generated in case of a normal test failure ) are also not generated in case of killing the gradle process .
You probably need to set maxParallelForks to 1.
Why don't you copy the approach used by Spring Security itself, which configures a separate task for integration tests? It sets maxParallelForks to 1 for those tests.
That way you can continue to benefit from running unit tests in parallel.

Resources