We run a CI environment with Jenkins and the Project is in ExtJS 3.2. I am not able to find a clear line on how to setup the test coverage for JS code in Jenkins. We write UI tests using selenium and Cucumber. The build file has a UI tests target which is run every time the CI machine runs a build. I am not able to find a plugin that will give me or publish the coverage report of these tests that have been run as a resulting atrifact in Jenkins.
Or please help me out if there is some other way to achieve the same thing.
I think you can use JSCover to generate code coverage when using Selenium:
Start JSCover java web service
Let Selenium hit the JSCover web-app and start the collector, also see the manual of JSCover about automated tests.
Run the Selenium tests in a new window or iFrame
Collect the coverage data and store it somewhere
Process the data into a nice report (possible with genhtml)
If you start a new browser for each Cucumber scenario/feature, then you need to save the coverage data between each scenario/feature, combine them after all features are done and then process them into a nice report. JSCover supports merging of multiple data sources and creating LCOV reports.
Related
Is there a way to run Selenium WebDriver tests in a browser (or just run a test scenario manually in a browser), and get the code coverage of the web-app written in JavaScript? Are there any other code coverage tools except JSCover that can do such task?
Is there a way to run Selenium WebDriver tests in a browser (or just
run a test scenario manually in a browser), and get the code coverage
of the web-app written in JavaScript?
JSCover can when run in proxy mode (without HTTPS). A more robust approach would be to pre-instrument your JS before running your tests, which can be done by JSCOver and other tools (see answer to second question).
JSCover can also save data between pages using local-storage which can be useful for re-using existing selenium suites.
You'll need to add some code to the end of your tests to save the coverage data. To do that with JSCover, see http://tntim96.github.io/JSCover/manual/manual.xml#fileSystemSave.
Are there any other code coverage tools except JSCover that can do
such task?
There is also Istanbul and BlanketJS which may be able to be used with the pre-instrumentation approach.
I am trying to run my mocha tests from node . The ultimate goal is to add code-coverage via istanbul/blanket and generate a lcov file for input into sonar for code coverage.
This is a sample project on which I am trying
https://github.com/rajarshigoswami/Todos
The mocha tests are under
https://github.com/rajarshigoswami/Todos/tree/master/test/mocha
The tests are running from browser, but when I am trying via node, it wont pick up any of the spec files.
How to use :
run : npm install
then : grunt
My questions are :
What am I missing or doing wrong here?
How do I integrate blanket.js/istanbul to generate lcov files
I would change a few things. Simply add this to package.json
"scripts": {
"test":
"./node_modules/.bin/istanbul test ./node_modules/.bin/_mocha -- -R spec"
}
Now, when you do npm test it runs mocha and istambul
This article will help you
There's a few options depending what you need to do:
1) So firstly it would be good to know what you actually mean by running tests in node? For example I use to mocha to test server-side code for my node.js applications. It just runs the tests without relying on any specific environment (except node.js obviously). Without any other tools simply run mocha your/custom/test/directory/ (that assume your mocha is installed globally).
So as long as your view test don't rely on being run in a Web Browser you're good.
2) If what you just want run your front-end tests without need of opening SpecRunner.html manually in a web browser, I highly recommend using karma test runner, with a headless browser like PhantomJS.
3) Finally if you already have the grunt installed just grab the mocha-istanbul npm module. The configuration is really simple:
mocha_istanbul: {
coverage: {
// where your tests leave
src: 'server/tests',
options: {
// instrument only spec files
mask: '*.spec.js',
// output a human readable website
// (along site regular test summary produced by mocha)
reportFormats: ['html']
}
}
}
So as you can see there are some options out there. Just grab the one that suits your project the best.
your problem is that you are trying to test code that using requirejs
in order for the you mocha spec to work with phantom and requirejs on a grunt task runner you can use grunt-mocha-phantomjs
for you other issue of using istambol check this link (this link is more suitable for your purpose because its use backbone also (-: )
I am having a small issue with WebStorm that I am hoping someone has experienced and solved before.
I am using WebStorm to build a angular.js app and I have it set up to use Karma to run my tests. This is fine for the most part: I have a Karma configuration setup and I can get to to run the tests or debug them with no issue.
My problem is that when I try to run a test individually by clicking on one of the test in the "Test Run" tree it goes off to a node configuration, tries to run it and fails (because its looking for js dependencies). After that I just go back to my 'karma config' and it runs through the whole of the test no problem.
Does anyone know how I can get the IDE hooked up so that I can trigger my tests from the UI?
Running tests from file right-click menu is only supported for those runners that allow executing individual tests (JSTestDriver, for example). There is currently no such possibility for Karma (WEB-13173). See the discussion at https://github.com/karma-runner/karma/issues/1235.
to run individual test files, you can have several karma configuration files with different sets of tests included. Plus you can rename individual tests/suits in the way mentioned in https://github.com/karma-runner/karma/issues/553
I have got javascript tests running in visual studio using Resharper and Jasmine. It all works fine. Now however I want to run an integration test. After looking into this I just can't work out whether I should be using Karma or PhantomJs or both? And whether they link to resharper?
I then have to run all my tests on the continuous integration server using Team City. Doesn't seem like there is a clear logical way to architect front end testing from dev right through to the CI server.
For example do I really need to use Karma locally and on the CI server? I don't want to because it is not baked into visual studio and I will have to keep opening the command line and running my tests manually. This will annoy other developers and they won't bother running them I imagine. Help!
We are using Team City by the way....
Neither of these test runners are connected to Resharper in any form. I don't think there is a one and only "correct" way of running Jasmine tests in TeamCity currently - for all approaches I am aware of there is a bit of assembly required.
Personally I am using a combination of PhantomJS and the Jasmine TeamCity Reporter which works like this:
Get a list of unique test URLs from server - each of these test suites will use the Jasmine TeamCity Reporter to log results
for each test URL dynamically generate a test JS file to be used for phantom and write it to disk
use PhantomJS to run the JS file which now will load the test suite page and its test result will be written to console where they are picked up by TeamCity.
I've been writing JavaScript unit tests using Jasmine. However, those tests run inside a browser, not as part of MSTest.
I want my TFS Continuous Integration builds to break when a JavaScript unit test fails. I know there is a solution for this in Visual Studio 2012, but I'm on 2010 (and will be for a long time in the future probably).
Is there an easy way to integrate Jasmine based JavaScript unit tests with TFS Build?
The Chutzpah test runner enables you to run your QUnit and Jasmine JavaScript unit tests from the command line or Visual Studio.
Therefore you should be able to integrate it into your TFS build via the InvokeProcess activity.
I'd use nodejs + jasmine-node, but you can also look at http://phantomjs.org/ with a junit reporter. Jasmine-node provides a junit reporter with the --junitreport output. You might also look at the TFS Build Extensions (http://visualstudiogallery.msdn.microsoft.com/2d7c8577-54b8-47ce-82a5-8649f579dcb6/view/Discussions/) and the activities in there. It includes a xml transform for JUnit to TRX (test results xml) which can be pushed into TFS.