How to Test Dynamic Logic
This page describes the process of testing dynamic logic using the Test Dynamic Logic Integration Point. A Unit Under Test (UUT) is the dynamic logic to test. A test case is a dynamic logic that tests the UUT.
Step 1 - Setting up the Unit Under Test
Create a dynamic logic function to test.
For example, a function that concatenates the first name and the last name.
The UUT uses a NAME FORMAT
signature, which accepts a Person entity and returns a character string.
Let the code for this dynamic logic be NAMEFORMAT_SIMPLE
.
nf = ""
if (person.initials) nf += person.initials + " "
if (person.name) nf += person.name
return nf
There can be multiple scenarios to consider.
-
both first and last names have a value
-
only last name has a value
You can create a separate test case for each scenario.
Step 2 - Setting up a Test Case
The test case is a dynamic logic that tests the UUT.
Our test case tests an existing person, say 12345
, with first name Bill and last name Johnson.
The test case checks for the successful execution of the UUT.
It adds a message No results in the logs when the UUT does not return any value.
The code for this dynamic logic is: NAMEFORMAT_SIMPLE_TEST01
.
// Assuming that there is a person with code 12345
def testperson = lookUpPerson("12345")
// call the UUT with the test person
def result = test( "NAMEFORMAT_SIMPLE", [
"person" : testperson
])
if (result) {
log.info("Result=" + result)
return "Bill Johnson".equals(result)
}
else {
// if result is null, the test case has failed
log.error("No result")
return false
}
Step 3 - Call the Test Dynamic Logic API
The following web service executes the test case.
HTTP Method |
POST |
Base URL |
http://<host>:<port>/<context-root>/testdynamiclogic/NAMEFORMAT_SIMPLE_TEST01 |
- Response
Error Code |
Description |
200 |
The test is successful and the unit under test( |
400 |
The test failed, and the UUT does not return any value. |