Your SlideShare is downloading. ×
Jasmine with JS-Test-Driver
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Jasmine with JS-Test-Driver

6,419
views

Published on

Explored various java-script test-runners, which are capable of supporting JS tests on major browsers, of which JS-Test-Driver stands the most promising...

Explored various java-script test-runners, which are capable of supporting JS tests on major browsers, of which JS-Test-Driver stands the most promising...

Published in: Technology

0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
6,419
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
3
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Problem Statement / Target
    Ability to run JavaScript tests through commandline (not exactly headlessly)
    Integrate test results with the Bamboo build plan
    Visibility of code-coverage
  • 2. Options for JS test-runner tools
    Env.js and Rhino.js
    V8 JavaScript Engine
    Jasmine-Maven plug-in
    Jasmine-Ruby plug-in
    Jasmine-JsTestDriver
  • 3. Env.js & Rhino.js
    Uses its own JS engine
    Is more closer to Mozilla Firefox
    Still does not even behave as a mirror image of Firefox, on commandline
    Findings: behaves as a different browser in itself
    V8 JavaScript Engine
    Google's open source JavaScript engine, used in chrome
    Is a C++ code-base, needs to be compiled on local machine
    Pretty capable, supports Mozilla and chrome, not sure about Safari
    Findings: Pretty capable, but have not explored much
  • 4. Jasmine-Maven Plug-in
    Uses HTMLUnit for headless browser runner
    HTMLUnit’s only supports Firefox and IE
    Findings – not capable to mock Safari capabilities
    Jasmine-Ruby Plug-in
    Has major issues with the “afterEach” and “toContains” Jasmine capabilities
    Can run with any browser – need to open the SpecRunner.html on the browser of choice !!!
    Findings – Promising, but needs to evolve
  • 5. JsTestDriver
  • 6. Why JsTestDriver
    Can run JS tests through commandline, on the browser(ant version) of choice
    Generates output in JUnit format, making it easier for Bamboo integration
    Well compatible with Jasmine
    Possesses code-coverage capability
    Had certain minor issues, which have a workaround now
  • 7. Workarounds required for JTD
    Not fully compatible with prototype.js – required jar fix
    Jasmine spy issue, was unable to remove the spies – required Jasmine-JsTestDriver Adapter fix
    Never closes the browser tab when test-runner completes – added a minor apple-script fix
  • 8. Testing with JTD
    jsTestDriver configuration
    server: http://localhost:9876
    load:
    - "tools/jasmine-test-driver/jasmine-1.0.1.js"
    - "tools/jasmine-test-driver/JasmineAdapter.js"
    - "tools/jasmine-test-driver/prototype-1.6.0.3.js"
    - "dist/qowt-browser-unitTests.js"
    rake test
    java -Xms512m -Xmx1024m
    -jar tools/jasmine-test-driver/JsTestDriver-1.2.2.jar
    --reset
    --port 9876
    --runnerMode DEBUG
    --browser open
    --tests all
    --testOutput tests/test-reports
  • 9. Creating test-append-area
    QOWT.TEST.UTILS = function() {
    return {
    /**
    * creates dummy Test Append Area, and appends it to the document object, for running tests headlessly
    * While executing tests on Sumulat, you get "testAppendArea" div present in the html body itself.
    * But, in case of jsTestDriver, you do not have any such div present, and will have to create it on the fly.
    * @return testAppendArea div
    */
    createTestAppendArea: function() {
    vartestAppendAreaContainer = document.getElementById('testAppendArea');
    if(testAppendAreaContainer === null) {
    testAppendAreaContainer = document.createElement("div");
    testAppendAreaContainer.innerHTML = '<div id="testAppendArea"></div>';
    document.body.insert(testAppendAreaContainer);
    }
    return document.getElementById('testAppendArea');
    }
    };
    }();
    USAGE: (CommonContentMrg-test.js)
    testAppendArea = QOWT.TEST.UTILS.createTestAppendArea();
    testAppendArea.appendChild(rootNode);
  • 10. Code-Coverage with JTD
    rake coverage
    http://quicknet/display/PROD/Generating+Code+Coverage+Reports
    Coverage configurations
    server: http://localhost:9876
    load:
    - "../jasmine-1.0.1.js"
    - "../JasmineAdapter.js"
    - "../prototype-1.6.0.3.js"
    - "../../../dist/qowt-browser-doc-sheet.js"
    - "../../../dist/qowt-browser-point.js"
    - "../../../dist/qowt-browser-testsOnly.js"
    plugin:
    - name: "coverage"
    jar: "tools/jasmine-test-driver/plugins/coverage-1.2.2.jar"
    module: "com.google.jstestdriver.coverage.CoverageModule"
  • 11. Debugging on JTD
    Start the server - java -Xms512m -Xmx1024m -jar tools/jasmine-test-driver/JsTestDriver-1.2.2.jar --port 9876
    Open the browser with the url- http://localhost:9876/capture
    Run the tests - java -Xms512m -Xmx1024m -jar tools/jasmine-test-driver/JsTestDriver-1.2.2.jar --tests all
    Apply the breakpoint
    Run the tests again
  • 12. Known issue with JTD
    The rake script fails to close Safari window, if it has the developer console opened !!!
  • 13. Questions … ?