Skip to content

Test Automation

ricardoquesada edited this page Mar 7, 2013 · 8 revisions

Test automation

Components

  1. Trigger the execution
  2. Run the tests
  3. Publish the results

Trigger the tests

Expected: Should trigger the execution of the tests on iOS, Android and some browsers after each commit in the cocos2d-js-tests

Current Status: Not started

Run the tests

Expected: All the tests should be run

Current Status:

  1. "Automated Test" button should be pressed
  2. Different test files should be executed manually
  3. Once each test file is opened, all the tests defined in that module are executed automatically

Publish Results

Expected: Results of the tests should be published in... TBD

Current Status: Not started

How to add new tests

BaseTestLayer class

In order to reuse the current cocos2d tests, an ad-hoc automation test was developed. This is a simple framework that iterates all over the tests that are defined in each test file.

The requirement is that each test should be a subclass of BaseTestLayer, and the following functions and properties shall be overridden:

    getExpectedResult:function() {
        return "Expected value";
    },
    getCurrentResult:function() {
        return "Current value";
    }

If the expected result is equal (string wise) to the current result, the test will be marked as Ok, otherwise as a Fail.

You can override the compare function too, in case you don't want to do an string-wise comparison:

    // Default comparison. Override to have a comparison.
    // return true if current and expected are the same
   //  return false otherwise
    compareResults:function(current, expected) {
        return (current == expected);
    },

Clone this wiki locally