oaUnitSetup()

The function oaUnitSetup determines where the test cases are saved.

Synopsis

int oaUnitSetup(string fileName, mapping options);

Parameter

Parameters Meaning
fileName The absolute path to test result file name.
options

The parameter "options" specifies the user specific test suite data, for example:

oaUnitSetup(_RESULT_FILE ,makeMapping("UserData", makeMapping("TestSuiteId", "MY-TEST-SUITE-NR-1",

"Version", "1.2.0.32",

"Platform", VERSION_PLATFORM,

"Tool", "oaUnit",

"TestType", "Unit")));

UserData can be an arbitrary type: int, float, mapping or a dyn variable.

Return Value

The error code. In case of wrong or missing parameters, the function returns -1 or -2. If the function was successfully executed, the function returns 0. If the function was not successfully executed, the function returns 1.

Error

The function returns the error code.

Description

The CTRL OA Unit CTRL extension contains a set of functions that can be used for testing purposes. The function oaUnitSetup determines where the test cases are saved.

Example

The example creates a test result file oaUnitTestResult2.txt in the log directory of the project and writes the test result of the test case "THIS-IS-MY-FIRST-ABORT-TEST-CASE" into this file.

#uses "CtrlOaUnit"
main()
{
  const string _RESULT_FILE = getPath(LOG_REL_PATH) + "oaUnitTestResult2.txt";
  oaUnitSetup(_RESULT_FILE, makeMapping("UserData", makeMapping("TestSuiteId", "MY-TEST-SUITE-NR-1",
  "Version", "1.2.0.32","Platform", VERSION_PLATFORM,
  "Tool", "oaUnit","TestType", "Unit")));
  /* Determines where the test cases are saved and specifies
  the file format and the user specific test suite data */
  int errCode;
  errCode = oaUnitAbort("THIS-IS-MY-FIRST-ABORT-TEST-CASE", "Since the test precondition failed");
  DebugN("oaUnitAbort -->", errCode);
}
Figure 1. The test result file oaUnitTestResult2.txt

For each test case a following line is added to the file:

DATE :<DD.MM.YYYY hh:mm:ss>, TCID:<TestCaseId>, METHOD:<nameOfTheMethod>, RESULT:<result in string format>, REFERENCE_VALUE:<referenceValue>, CURRENT_VALUE:<CurrentValue>, LOWER_BOUND:<LoverBound>, UPPER_BOUND:<UpperBound>, TS_DATA:<testSuiteData – optional>, TC_DATA:<testCaseData – optional>

METHOD - method name, possible names: oaUnitPass, oaUnitFail, oaUnitAbort, oaUnitAssertTrue, oaUnitAssertFalse, oaUnitAssertEqual, oaUnitAssertNotEqual, oaUnitAssertGreater, oaUnitAssertLess, oaUnitAssertEqualDelta, oaUnitAssertNotEqualDelta

RESULT - possible entries: PASS, FAIL, ABORT.

TS_DATA - Test suite data that can be used via the function oaUnitSetup as user data.

TC_DATA - Test case data that can be set via the oaUnitAssert* functions as user data

Assignment

CTRL OA Unit DLL

Availability

CTRL

See also

CTRL OA Unit, Basics