SysTestCase.parmExceptionExpected Method [AX 2012]

Determines whether an exception is expected in the current test.

public boolean parmExceptionExpected([boolean _value, str _exceptionMessage])

Run On

Called

Parameters

_value
Type: boolean
A Boolean value that indicates whether an exception is expected; optional.
_exceptionMessage
Type: str
The exception message of the expected exception; optional.

Return Value

Type: boolean
true if an exception is expected; otherwise, false.

If the exception message is specified, the message must match the thrown exception exactly; otherwise, any exception thrown is acceptable.

The following example demonstrates how the SysTestCase.parmExceptionExpected method could be used to test the fictitious Employee class.

void testRetire() 
{ 
    // Create an instance of the employee. 
    Employee employee = new Employee(); 
  
    // Call the retire method, first time should be successful. 
    employee.retire(); 
 
    // Assert that an exception is expected. 
    this.parmExceptionExpected(true, "Already retired"); 
 
    // Call the retire method. An exception is expected. 
    employee.retire(); 
}

Community Additions

ADD
Show: