Web Unit Testing Tool
The Web unit testing tool provides a set of features for testing the source code. The tool uses the QUnit test framework to write and run tests.
To unit test your application:
Note |
---|
The Web unit test tool is designed to only support functional testing. |
Generating Test Stubs
You can generate unit tests easily with the New Web Unit Test wizard.
To test your project:
- To open the wizard, go to File > New > Tizen Web Unit Test.
- Select the file to test from the file list on the left pane.
- Select the methods to test from the method list on the right pane.
- Enter a name for the test file and click Finish.
Figure: Generating a test stub
The test stubs are generated in the webUnitTest folder.
Figure: Test stub location
Editing a Test
To edit a unit test:
-
Add a test case using the test() function:
test(name, test2);
The function takes the following parameters:
- name: The title of the test as string, which is used to display the test results.
- test2: The function contains actual testing code that is written with one or more assertions to test.
-
Edit test2 using assertions.
An assertion is a boolean expression that meaning pass or failure of test. You can test a value generated by your code with expected value using a number of assertions provided by Web unit testing tool.
Note For more information about assertions, see http://api.qunitjs.com/category/assert/.
Running Tests
To run a unit test, right-click on your project in the Package Explorer view and select Run As > Tizen Web Unit Test Application.
The Web Unit Test Result view shows the test results in a tree format. It shows the passed tests with a green icon and failed tests with a red icon. You can use the Show failed only button to only display the failed tests.
Figure: Test result
To repeat the test, select a checkbox and click the Run checked button.
Figure: Repeating a test