Configure project for Jasmine Test Case using Oracle Weblogic - node.js

I am having a web based project which I deploy in weblogic server as EAR for execution. I need to implement Jasmine for unit testing.
I came to know that Jasmine can be executed in NodeJS server but my project has some servlets also as a part of it. So, how can I configure Jasmine to run on oracle weblogic server.
Also, if it is possible by any other means like integrating weblogic with NodeJS (I am not sure about this.) , kindly explain me the process to set up.

I wouldn't try to run your Jasmine tests from WebLogic. That is like saying you want to run your JUnit tests on WebLogic.
JUnit tests are run from the command line in your development environment (often wrapped by the IDE) and also on your CI build agent. Jasmine tests should follow the same pattern. You shouldn't have to go through an entire deploy cycle just to run your unit tests.
I suggest looking at using Karma to run your tests, both locally and on CI.

Related

Running Coded UI tests from MTM without a build?

I have created a few coded ui tests and linked them to the test case, and they now appear as automated and you can see the dll they link to in the test case details.
Now that I want to run the tests, MTM refuses to even start the test unless a build is defined.
However: I want to run the tests against a statically installed application in the lab environment. This is an application that I manually install, and I get this application already compiled, so no need to play around building it.
So how can I take the build server out of the loop? I don't need the application built or deployed, I'm already doing that.
All I want is the tests to run on the lab environment specified against an application that is already preinstalled.
It's asking you to define the build of the test solution, assuming that it's different from your application under test. The test assembly will be deployed to the test environment after you specify it in MTM. This article may help you with the specifics.
It is asking you to create a build for your Coded UI test solution. It requires that the tests be built so that it has something to execute when you run the tests. Assuming that your tests were recorded using your statically deployed application then they will test that same application.

can I use karma to test page interaction like drag & drop?

I'm evaluating end to end testing of a MEAN stack app. There's a few critical spots in the app where drag and drop (via a directive) is used. I can't find any information about using karma to test this. Is it possible? If not, what library would you recommend?
Yes, Angular comes bundled with e2e testing that can be run via Karma. The angular-seed application is a good example of a project structure that includes both e2e and unit tests. From the project home page:
End to end testing
Angular ships with a baked-in end-to-end test runner that understands
angular, your app and allows you to write your tests with jasmine-like
BDD syntax.
Requires a webserver, node.js + ./scripts/web-server.js or your
backend server that hosts the angular static files.
Check out the end-to-end runner's documentation for more info.
create your end-to-end tests in test/e2e/scenarios.js
serve your project directory with your http/backend server or node.js +
scripts/web-server.js
to run do one of:
open http://localhost:port/test/e2e/runner.html in your browser
run the tests from console with Karma via scripts/e2e-test.sh or script/e2e-test.bat
Also, it should be noted that apparently the Angular team will be replacing this current e2e setup with Protractor at some point in the future.

Running Unit Tests on NodeJS with Jenkins

How might I setup Jenkins to start my Node.JS Testing Server, run Unit Test probably JSTestDriver/Jasmine, and then top Node.JS?
I can start Node.JS using Execute Shell, but it "hangs" the build (expected since Node runs as a daemon)
I've written an article that explains how I've managed to run my unit tests with Mocha and ant.
The basic idea is:
Set your environment variables so that jenkins can control them
Use mocha's xunit reporter to generate a result report
Use Jenkins' Publish JUnit test result report option to read the result report.
You can read the full article here.
JSTestDriver outputs it's results in a xUnit compliant xml format. Which the Hudson 'xUnit' plugin can then interpret.
We are planning to integrate jsTestDriver into Jenkins. To test our javaScript code in a selection of supported browsers.
there is a plugin to execute nodejs with possibility to choice the nodejs version
https://wiki.jenkins-ci.org/display/JENKINS/NodeJS+Plugin

Jenkins + qUnit

How to easily integrate Jenkins with qUnit? I gonna use real browser (like firefox and chrome) to run tests. My server runs on RedHat 6.1 Linux. I think I have all needed plugins/libraries but I still don't know how to make it working. I'm working with Jenkins 1st time (on server side).
//Edit:
It would be wonderful if someone can share idea how to build coverage report too.
Thanks in advance :).
Saying Jenkins and QUnit is only part of the puzzle. You still need a web browser and a way to get a JUnit style XML file from the QUnit results on to disk. While there is Selenium and Webdriver for controlling numerous browsers, the easiest way to get started is to use PhantomJS (http://phantomjs.org/). PhantomJS is a headless webkit based browser meant just for tasks like this.
If you browse the "Test Frameworks" sections of this page ( http://code.google.com/p/phantomjs/wiki/WhoUsesPhantomJS ) you will see several scripts for running QUnit (some with JSCoverage support). The phantomjs-jscoverage-qunit script looks like it will hit all the major points you want to hit, as does United. Both look like they will require some fiddling to get them going though.
Alas, I haven't discovered any method for running QUnit tests and getting JUnit output for either Selenium, WebDriver, or PhantomJS that will just work without modification.
EDIT: Now several months later, it have become clear to me that webdriver is the future of Selenium (it probably should have been clear to me back then, but it wasn't). Also, PhantomJS now works with WebDriver via GhostDriver, so supporting only WebDriver and choosing PhantomJS as a target is probably the best advice going forward.
It's been over a year since this question was posted, but there is a Jenkins plugin for TestSwarm. My layman's understanding is that you can use TestSwarm run your QUnit tests continuously across all of the major browsers. It is open sourced on GitHub.
Disclosure: I'm contributor of the Arquillian project.
You can use the Arquillian Qunit Extension open source extension to execute your QUnit tests on Jenkins. In general, Arquillian Qunit Extension can be easily used in continuous integration environments. On this GitHub repo you can find a real example of how Arquillian Qunit Extension can be used to execute QUnit tests on Travis CI headless machines.
Arquillian is a JBoss Community project.
Arquillian Qunit Extension is is an Arquillian extension which automates the QUnit JavaScript testing. Arquillian Qunit Extension integrates transparently with the JUnit testing framework.
You can find more information on this README file. In addition, there is a showcase which can be executed through Maven and shows how to setup your test case.
Using this extension, you have the option to deploy an archive during the QUnit test executions and/or execute one or more QUnit Test Suites in a single execution. Furthermore you can define the QUnit Test Suite execution order using the #InSequence annotation.
For example, assume that you want to execute two QUnit Test Suites (qunit-tests-ajax.html and qunit-tests-dom.html) and that your QUnit tests included in these test suites perform Ajax requests to a Web Service. Apparently, you need this Web Service to be on host while the tests are executed. Arquillian can automatically perform the deployment of the Web Service to a container. In a such case your Arquillian test case will look like:
#RunWith(QUnitRunner.class)
#QUnitResources("src/test/resources/assets")
public class QUnitRunnerTestCase {
private static final String DEPLOYMENT = "src/test/resources/archives/ticket-monster.war";
/**
* Creates the Archive which will be finally deployed on the AS.
*
* #return Archive<?>
*/
#Deployment()
public static Archive<?> createDeployment() {
return ShrinkWrap.createFromZipFile(WebArchive.class, new File(DEPLOYMENT));
}
/**
* Execute the qunit-tests-ajax.html QUnit Test Suite.
*/
#QUnitTest("tests/ticketmonster/qunit-tests-ajax.html")
#InSequence(1)
public void qunitAjaxTests() {
// empty body - only the annotations are used
}
/**
* Execute the qunit-random-tests.html QUnit Test Suite.
*/
#QUnitTest("tests/ticketmonster/qunit-random-tests.html")
#InSequence(2)
public void qunitRandomTests() {
// empty body - only the annotations are used
}
}
If using real browsers:
Run the QUnit tests in multiple browsers simultaneously by using bunyip (https://github.com/ryanseddon/bunyip). It is built on top of Yeti which can provide JUnit XML compatible reports - thus readable by Jenkins
If using PhantomJS (headless browser which acts almost like a real WebKit based one):
Just shared here https://stackoverflow.com/a/17553889/998008 a walk-through on adding QUnit test runner task into Apache Ant build script. Jenkins runs the script while pulling project working copy from a VCS. You need to specify in Jenkins project the location of the output file. Output is JUnit XML compatible.
BlanketJS is a fantastic code coverage tool that works well with QUnit. I've been using it for about a year now.
For Jenkins integration, I use grunt which exits with a 0 if the grunt task fails, and 1 if it passes, so it integrates with Jenkins perfectly.
There was no existing Grunt plugin that handled Blanket and QUnit together, so I wound up writing my own Grunt plugin. The plugin supports "enforcement" of a minimum threshold, or else the Grunt task fails.
I wrote a blog post with all the details here: http://www.geekdave.com/2013/07/20/code-coverage-enforcement-for-qunit-using-grunt-and-blanket/

Is it possible to integrate Jasmine into cruise control.net

Is it possible to automatically run a jasmine test suite as part of a cruise control.net build?
And If so how?
My server code is C# and I already had my CI server running lots of unit tests. So I added a unit test that uses Watin to launch a browser to run the Jasmine tests and check the results. It took a morning to get all the pieces playing happily together.
An alternative might be to investigate NJasmine -- I saw this was available on NuGet but didn't pursue this myself partly due to lack of documentation.
Also, if you're using ReSharper, you might like to look at their integration with QUnit: http://blogs.jetbrains.com/dotnet/2011/03/resharper-6-introduces-support-for-javascript-unit-testing/ (there's every chance they'll integrate it with Jasmine too). Although this is aimed at running JS UTs within Visual Studio, you might find it offers you a "hook" to run them from your CI server too.

Resources