If you are implementing a component in your application, you must test it to ensure that it does not behave in an unexpected way. Well-tested applications that perform as expected improve user satisfaction. Testing can also help you develop your applications faster and further, with less wasted effort.
A unit of code is the smallest testable component of your project, such as a class or a method.
You can create unit tests easily with the Web Unit Test wizard.
To test your project:
Figure: Creating a Web unit test
The Web unit tests are generated in the
Figure: Web unit test location
To edit a unit test:
Add a test case using the
The function takes the following parameters:
name: Title of the test as a string, used to display the test results
test2: Function containing the actual testing code that is written with 1 or more assertions to test
test2 parameter using assertions.
An assertion is a Boolean expression that means pass or failure in the test. You can test a value generated by your code with the expected value using a number of assertions provided by the Web unit testing tool.
For more information on assertions, see http://api.qunitjs.com/assert/.
To run a unit test:
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. To only display the failed tests, you can use the Show failed only button (marked with a red rectangle in the following figure).
Figure: Web unit test application result
To repeat the test, select its check box and click the Run checked button (marked with a red rectangle in the following figure).
Figure: Repeating a test