SysTestCase Class [AX 2012]
The SysTestCase class defines the structure for tests in the Unit Test framework.
| Method | Description | |
|---|---|---|
| assertEquals | Checks whether two values are equal. (Inherited from SysTestAssert.) |
| assertExpectedInfoLogMessage | Validates that an expected message has been put in the Infolog. |
| assertFalse | Checks whether a condition is not true. (Inherited from SysTestAssert.) |
| assertNotEqual | Checks whether two values are not equal. (Inherited from SysTestAssert.) |
| assertNotNull | Checks whether the value is not nullNothingnullptrunita null reference (Nothing in Visual Basic). (Inherited from SysTestAssert.) |
| assertNotSame | Checks whether the objects are not the same. (Inherited from SysTestAssert.) |
| assertNull | Checks whether the value is nullNothingnullptrunita null reference (Nothing in Visual Basic). (Inherited from SysTestAssert.) |
| assertRealEquals | Checks whether two values are equal with regard to a delta. (Inherited from SysTestAssert.) |
| assertSame | Checks whether the objects are the same. (Inherited from SysTestAssert.) |
| assertTrue | Checks whether the condition is true. (Inherited from SysTestAssert.) |
| cancelTimeOut | Cancels a previous method call to the setTimeOut method. (Inherited from Object.) |
| createSuite | Constructs the test suite used by this test case. |
| equal | Determines whether the specified object is equal to the current one. (Inherited from Object.) |
| exceptionExpected | Indicates whether the current test is expected to throw an exception. |
| exceptionMessage | Gets the exception message of the expected exception. |
| fail | Fails the current test case. (Inherited from SysTestAssert.) |
| faultCode | |
| faultExpected | |
| faultReason | |
| findTestTarget | |
| getListenerInformation | Gets the listener information for the test method. |
| getTimeOutTimerHandle | Returns the timer handle for the object. (Inherited from Object.) |
| handle | Retrieves the handle of the class of the object. (Inherited from Object.) |
| info | Logs an informational message to the Infolog. (Inherited from SysTestAssert.) |
| new | Initializes a new instance of the SysTestCase class. (Overrides the new Method.) |
| notify | Releases the hold on an object that has called the wait method on this object. (Inherited from Object.) |
| notifyAll | Releases a lock on the object that was issued by the wait method on this object. (Inherited from Object.) |
| objectOnServer | Determines whether the object is on a server. (Inherited from Object.) |
| owner | Returns the instance that owns the object. (Inherited from Object.) |
| parmExceptionExpected | Determines whether an exception is expected in the current test. |
| parmFaultExpected | |
| run | Runs the test case. |
| setTimeOut | Sets up the scheduled execution of a specified method. (Inherited from Object.) |
| setUp | Sets up the test case environment. |
| setUpTestCase | Sets up the test environment for the test case. |
| tearDown | Tears down the test case environment. |
| tearDownTestCase | Tears down the test environment for the test case. |
| testMethods | Returns the test methods for a test case. |
| testsElementName | Gets the name of the code coverage element. |
| testsElementType | Gets the type of the code coverage element. |
| toString | Returns a string that represents the current object. (Inherited from Object.) |
| usageCount | Returns the current number of references, that is, the value of the reference counter, that the object has. (Inherited from Object.) |
| useSingleInstance | Determines the lifetime of the test case instance used to execute the test methods of the test case. |
| wait | Pauses a process. (Inherited from Object.) |
| wasExpectedInfoLogMessageThrown | Checks whether the expected exception message has been put in the Infolog. |
| xml | Returns an XML string that represents the current object. (Inherited from Object.) |
Steps to create a test case:
-
Create a class that derives from the SysTestCase class.
-
Optionally initialize the test state by overriding the setUp method.
-
Optionally clean up the test state by overriding the tearDown method.
-
Add tests as public methods that are prefixed with "test" and have no parameters or return value.
The following code example tests the fictitious Employee class.
class EmployeeTest extends SysTestCase
{
Employee employee;
public void setUp()
{
// Create an instance of the Employee class for each test method.
employee = new Employee("your name");
super();
}
void testName()
{
// Verify that the name is set.
this.assertEquals("your name", employee.name());
}
}
Community Additions
ADD
Show: