View source | Discuss this page | Page history | Printable version   
Toolbox
Main Page
Upload file
What links here
Recent changes
Help

PDF Books
Add page
Show collection (0 pages)
Collections help

Search

How to create QUnit testcases

Contents

Overview

Openbravo provides QUnit library as framework to write JavaScript unit test cases.


QUnit-logo.png

The flow

QUnit test cases defined within Openbravo are executed by opening http(s)://your.server/openbravoContext/web/org.openbravo.client.kernel/ui-test-suite/ URL. When accessing this URL this flow is executed:

Creating a new QUnit test case

Declaring JavaScript test resources

Openbravo QUnit test cases are written as JavaScript static resources, which needs to be declared in the ComponentProvider of the module that deploys them. They must be declared in the getTestResources method.

 
@ApplicationScoped
@ComponentProvider.Qualifier(ExampleComponentProvider.EXAMPLE_VIEW_COMPONENT_TYPE)
public class ExampleComponentProvider extends BaseComponentProvider {
    @Override
  public List<String> getTestResources() {
    final List<String> testResources = new ArrayList<String>();
    testResources.add("web/org.openbravo.client.application.examples/js/test/my-test.js");
    return testResources;
  }
}
Bulbgraph.png   JavaScript test resources are only loaded when QUnit test cases are executed, they are not part of the common static resources that compose the application.

Implementing a test case

Once the file with the test case is declared in the ComponentProvider it will be loaded when QUnit test cases are executed.

Test cases look like:

 
/*global QUnit */
 
QUnit.module('org.openbravo.my.module');
 
QUnit.test('Test 1', function () {
  QUnit.expect(2);
  QUnit.ok(isc, 'isc object is present');
  QUnit.ok(OB, 'OB object is present');
});
 
QUnit.test('Test 2', function () {
 // ...
});

Comprehensive documentation can be found in the QUnit site.

Executing

All QUnit test cases are executed by just opening http(s)://your.server/openbravoContext/web/org.openbravo.client.kernel/ui-test-suite/ URL.

QUnit-execution.png

Continuous Integration

All Qunit test cases defined within Openbravo 3 distribution modules are automatically executed as part of the Continuous_Integration.

All of them appear in int-gui > com.openbravo.test.integration.qunit.testscripts > QUnitExecution

Retrieved from "http://wiki.openbravo.com/wiki/How_to_create_QUnit_testcases"

This page has been accessed 736 times. This page was last modified on 8 May 2015, at 17:42. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.