Академический Документы
Профессиональный Документы
Культура Документы
Background
Unit test is based on Test-driven development (TDD), which drives the design of software and forces
decoupling of dependencies. This practice results a comprehensive suite of unit tests that can be run at
any time to provide feedback that the software is still working.
Naming Convention:
Name the test class by using the same name as the class it is testing followed by the word
Test.
This associates the test with the test case. It also enables the Unit Test framework to
collect code coverage data for the class.
Example
This example illustrates how to declare a test class. You can attach an attribute to the
class. This example attaches the (SysTestTargetAttribute) attribute to specify the
target class that is tested Employee. This is usually used to redirect the target to a
table.
method to provide
more
information. For
example,
Examples
To specify the target class for your test
This example illustrates how to attach an attribute to a class to specify that it should
be used for a test. This example attaches the SysTestTargetAttribute attribute to
specify the class that is tested is the Employee class.
To specify which methods on the unit test class are test methods
To specify which tests are tests for check in and integrate with a version control
system
You can run and classify the most critical test methods as check in tests. When you
set up the version control system, you can specify which test project to run during
check in. You can also specify whether to run all test methods, or only the test
methods that are marked as check in tests.
The following table describes the assertion methods on the SysTestCase class.
The Employee class should have the following code in the classDeclaration:
3. In the AOT, right-click the EmployeeTest class, point to Override method and then click
setup.
4. In the Code Editor, change the setup method to the following code.
5. In the AOT, right-click the EmployeeTest class, point to Override method and then click
createSuite.
6. In the Code Editor, change the createSuite method to the following code.
Next, you can run a test case and analyze the results.
Prepared by Ashraf : )