k-test-core
Service icon

K Test Core

Stable version 1.2.1 (Compatible with OutSystems 11)
Uploaded
 on 2 Feb
 by 
5.0
 (1 rating)
k-test-core

K Test Core

Documentation
1.2.2

The K Test Core library provides a framework for configuring and running automated unit and integrations tests. It will run tests on client and server actions.

Use the K Test Manager forge component to provide a user interface for the to the manage test cases.

The forge components are separated as your code will depend on this component, whereas the K Test Manager only needs to be deployed to the dev environment.

How to Write a Server Test Case

A test case verifies the result for a scenario of use, or "case", of a target operation.

Decide on the action or component, known as the target, to be tested. Then decide on the scenarios to test. Scenarios could include single value, multiple values, zero values, expected exceptions. It helps to Consider the "contract" of the target to determine scenarios.

Note: Consider using the Server Action Tests screen template to create the boilerplate code for your test cases. It will create the server actions for the test; then just delete the screen.

To write a server test case

  1. Create an server action naming it with the target and scenario.

    For example, testing an action ProcessStructure with large data values call the test Test_ProcessStructure_WithLargeData

  2. Add a parameter called ScriptRunId of type TestScriptRun Identifier. Pass the ScriptRunId from the REST API method to the action.
  3. Call TestCaseRun_Start to start the test case. It takes a TestScriptRun Identifier parameter and will associate results with the active script run.
  4. Set the Name as the name of the scenario. eg "With Large Data"
  5. Set the Target as the action or component being tested.
    eg ProcessStructure
  6. Store the TestCaseRunId returned from the TestCaseRun_Start action in a local variable
  7. Add an exception handler for AllExceptions which should call the Assert_ExceptionThrown action. This ensures an failure is recorded if an exception is thrown.
  8. Set up the data to be tested. This is the "Arrange" step.
  9. Call the action to test. This is the "Act" step.
  10. Use Assertion service actions from the KTest_CS module to check the results of the action. Create as many assertions as you need. This is the "Assert" step.
  11. Call TestCaseRun_End to complete the test case. If any assertions have failed, the test case will be set to failed.

Write as many test cases and call them from the REST API. This is your test script.

Expose a REST API to Run the Script

Expose a REST API for the Test Manager to call when the script runs.

To expose a REST API for the script

  1. In the module where you will write tests, navigate to Logic > Integrations > REST.
  2. Right-click on REST and select Expose REST API. Give it a name, eg UnitTests
  3. Under Security, set Internal Access Only to Yes.
  4. Set the Authentication property. Note this should match the Authentication Scheme set when you configure a script to call the REST API.
    1. For None, double check Internal Access Only is checked.
    2. For Basic, you will need to specify the username and password when you configure the script.
    3. For Custom, implement the OnAuthentication method. Call GetRequestHeader (From the HttpRequestHandler module) to get the "Authorization" header. Then call TestScriptRun_AuthenticateBearerToken() passing the value of the Authorization header.
  5. Right-click on the API and select Add REST API Method. Name the method, eg RunTests
  6. Set the HTTP Method to POST (otherwise you will get a MethodNotAllowed error).
  7. Add a parameter to the method named Request. Ensure Receive In is set to Body. Set its Data Type to structure TestScriptRequest from KTest_CS. Notice the structure has a single parameter ScriptRunId of type TestScriptRun identifier. This parameter is required to record test cases for the script run.
  8. In the method call a server action to run the unit tests.

Client Side Tests - Installation

The "K Test Client Actions Core" library contains all the client actions required to write unit tests for client actions. It depends on K Test Core.

Client unit tests are run on the server using Puppeteer. You can also run client tests manually by opening the page yourself.

To add the library:

  1. In Service Studio, click on Install from Forge.
  2. Find the "K Test Client Actions Core" library and install it.
  3. Open the module where you will write unit tests for client actions.
  4. Add dependencies from KTestClientActionsCore to your module.
    1. TestScript client actions
    2. TestCase client actions
    3. All the Assert actions you need for your unit tests.

Now write each set of unit tests as a test script.

How to Write a Client Test Script

The test script runs all the test cases for the script (see below for writing a test case).

Consider using the Client Action Tests screen template to create the boilerplate code for your test cases. It will create the screen and client actions for the test.

To write a test script

  1. Create a page to run the test script, eg "RunTests". Create this page in a separate test application if you client actions are public.
  2. Limit permissions to users with the TestAdministrator role from KTest_CS.
  3. Add a client action to the page called RunTestScript() that returns a parameter Results of data type TestScriptBatchResult.
  4. Call RunTestScript() either from a button click or OnReady or both.
  5. In RunTestScript() call TestClientScriptRun_Start and pass the name and description of the test script. Assign the returned structure to the Results output parameter.
  6. Run all the test cases (see below) and assign the returned cases structure to Results.Cases.
  7. Call TestClientScriptRun_RecordBatch with the Results.
  8. Then call TestClientScriptRun_End passing the Results.ScriptRunId.
  9. Add an exception handler for AllExceptions and call TestClientScriptRun_Failed passing Results.ScriptRunId and the exception message. This will record the test script as failed.

Write as many test cases as you need. This is your test script.

Add the TestResultsBlock to your page to display the test results immediately. Otherwise view results of tests in the K Test Manager.

How to Write a Client Test Case

The test case verifies a particular "target", normally a client action, for a particular scenario.

To write a test case

  1. Create an action naming it with the target and scenario.
  2. For example, testing an action ProcessStructure with large data values call the test Test_ProcessStructure_WithLargeData
  3. Add a parameter called ScriptRunId of type TestScriptRun Identifier. Pass the ScriptRunId from RunTestScript action.
  4. Add an output parameter "Case" of type TestCaseResult.
  5. Call TestClientCaseRun_Start to start the test. Set the Name as the name of the scenario. eg "With Large Data". Set the Target as the action or component being tested. eg ProcessStructure
  6. Assign the returned structure to the output parameter "Case".
  7. Add an exception handler for AllExceptions which should call the TestClientCaseRun_Exception action. This ensures a failure is recorded if an exception is thrown. Although, if the exception is expected,
  8. use Assert_ExpectedException instead, and 
  9. add an Assertion that always fails after the exception should
  10. have been thrown.
  11. Set up the data to be tested. This is the "Arrange" step.
  12. Call the action to test. This is the "Act" step.
  13. Use Assert client actions from the KTestClientActionsCore module to check the results of the action. Create as many assertions as you need. This is the "Assert" step.
  14. Call TestClientCaseRun_End passing the "Case" output parameter to complete the test case. Assign the "Case" output parameter to the result of the TestClientCaseRun_End action.

Have a look at the demo app KTestClientActionsDemo to see an example of client unit tests. Notice it has a pattern for creating a unit test template for testing a particular client action. This pattern helps writing unit tests quickly for differing scenarios.


1.2.1

The K Test Core library provides a framework for configuring and running automated unit and integrations tests. It will run tests on client and server actions.

Use the K Test Manager forge component to provide a user interface for the to the manage test cases.

The forge components are separated as your code will depend on this component, whereas the K Test Manager only needs to be deployed to the dev environment.

How to Write a Server Test Case

A test case verifies the result for a scenario of use, or "case", of a target operation.

Decide on the action or component, known as the target, to be tested. Then decide on the scenarios to test. Scenarios could include single value, multiple values, zero values, expected exceptions. It helps to Consider the "contract" of the target to determine scenarios.

Note: Consider using the Server Action Tests screen template to create the boilerplate code for your test cases. It will create the server actions for the test; then just delete the screen.

To write a server test case

  1. Create an server action naming it with the target and scenario.

    For example, testing an action ProcessStructure with large data values call the test Test_ProcessStructure_WithLargeData

  2. Add a parameter called ScriptRunId of type TestScriptRun Identifier. Pass the ScriptRunId from the REST API method to the action.
  3. Call TestCaseRun_Start to start the test case. It takes a TestScriptRun Identifier parameter and will associate results with the active script run.
  4. Set the Name as the name of the scenario. eg "With Large Data"
  5. Set the Target as the action or component being tested.
    eg ProcessStructure
  6. Store the TestCaseRunId returned from the TestCaseRun_Start action in a local variable
  7. Add an exception handler for AllExceptions which should call the Assert_ExceptionThrown action. This ensures an failure is recorded if an exception is thrown.
  8. Set up the data to be tested. This is the "Arrange" step.
  9. Call the action to test. This is the "Act" step.
  10. Use Assertion service actions from the KTest_CS module to check the results of the action. Create as many assertions as you need. This is the "Assert" step.
  11. Call TestCaseRun_End to complete the test case. If any assertions have failed, the test case will be set to failed.

Write as many test cases and call them from the REST API. This is your test script.

Expose a REST API to Run the Script

Expose a REST API for the Test Manager to call when the script runs.

To expose a REST API for the script

  1. In the module where you will write tests, navigate to Logic > Integrations > REST.
  2. Right-click on REST and select Expose REST API. Give it a name, eg UnitTests
  3. Under Security, set Internal Access Only to Yes.
  4. Set the Authentication property. Note this should match the Authentication Scheme set when you configure a script to call the REST API.
    1. For None, double check Internal Access Only is checked.
    2. For Basic, you will need to specify the username and password when you configure the script.
    3. For Custom, implement the OnAuthentication method. Call GetRequestHeader (From the HttpRequestHandler module) to get the "Authorization" header. Then call TestScriptRun_AuthenticateBearerToken() passing the value of the Authorization header.
  5. Right-click on the API and select Add REST API Method. Name the method, eg RunTests
  6. Set the HTTP Method to POST (otherwise you will get a MethodNotAllowed error).
  7. Add a parameter to the method named Request. Ensure Receive In is set to Body. Set its Data Type to structure TestScriptRequest from KTest_CS. Notice the structure has a single parameter ScriptRunId of type TestScriptRun identifier. This parameter is required to record test cases for the script run.
  8. In the method call a server action to run the unit tests.

Client Side Tests - Installation

The "K Test Client Actions Core" library contains all the client actions required to write unit tests for client actions. It depends on K Test Core.

Client unit tests are run on the server using Puppeteer. You can also run client tests manually by opening the page yourself.

To add the library:

  1. In Service Studio, click on Install from Forge.
  2. Find the "K Test Client Actions Core" library and install it.
  3. Open the module where you will write unit tests for client actions.
  4. Add dependencies from KTestClientActionsCore to your module.
    1. TestScript client actions
    2. TestCase client actions
    3. All the Assert actions you need for your unit tests.

Now write each set of unit tests as a test script.

How to Write a Client Test Script

The test script runs all the test cases for the script (see below for writing a test case).

Consider using the Client Action Tests screen template to create the boilerplate code for your test cases. It will create the screen and client actions for the test.

To write a test script

  1. Create a page to run the test script, eg "RunTests". Create this page in a separate test application if you client actions are public.
  2. Limit permissions to users with the TestAdministrator role from KTest_CS.
  3. Add a client action to the page called RunTestScript() that returns a parameter Results of data type TestScriptBatchResult.
  4. Call RunTestScript() either from a button click or OnReady or both.
  5. In RunTestScript() call TestClientScriptRun_Start and pass the name and description of the test script. Assign the returned structure to the Results output parameter.
  6. Run all the test cases (see below) and assign the returned cases structure to Results.Cases.
  7. Call TestClientScriptRun_RecordBatch with the Results.
  8. Then call TestClientScriptRun_End passing the Results.ScriptRunId.
  9. Add an exception handler for AllExceptions and call TestClientScriptRun_Failed passing Results.ScriptRunId and the exception message. This will record the test script as failed.

Write as many test cases as you need. This is your test script.

Add the TestResultsBlock to your page to display the test results immediately. Otherwise view results of tests in the K Test Manager.

How to Write a Client Test Case

The test case verifies a particular "target", normally a client action, for a particular scenario.

To write a test case

  1. Create an action naming it with the target and scenario.
  2. For example, testing an action ProcessStructure with large data values call the test Test_ProcessStructure_WithLargeData
  3. Add a parameter called ScriptRunId of type TestScriptRun Identifier. Pass the ScriptRunId from RunTestScript action.
  4. Add an output parameter "Case" of type TestCaseResult.
  5. Call TestClientCaseRun_Start to start the test. Set the Name as the name of the scenario. eg "With Large Data". Set the Target as the action or component being tested. eg ProcessStructure
  6. Assign the returned structure to the output parameter "Case".
  7. Add an exception handler for AllExceptions which should call the TestClientCaseRun_Exception action. This ensures a failure is recorded if an exception is thrown. Although, if the exception is expected,
  8. use Assert_ExpectedException instead, and 
  9. add an Assertion that always fails after the exception should
  10. have been thrown.
  11. Set up the data to be tested. This is the "Arrange" step.
  12. Call the action to test. This is the "Act" step.
  13. Use Assert client actions from the KTestClientActionsCore module to check the results of the action. Create as many assertions as you need. This is the "Assert" step.
  14. Call TestClientCaseRun_End passing the "Case" output parameter to complete the test case. Assign the "Case" output parameter to the result of the TestClientCaseRun_End action.

Have a look at the demo app KTestClientActionsDemo to see an example of client unit tests. Notice it has a pattern for creating a unit test template for testing a particular client action. This pattern helps writing unit tests quickly for differing scenarios.


1.2.0

The K Test Core library provides a framework for configuring and running automated unit and integrations tests. It will run tests on client and server actions.

Use the K Test Manager forge component to provide a user interface for the to the manage test cases.

The forge components are separated as your code will depend on this component, whereas the K Test Manager only needs to be deployed to the dev environment.

How to Write a Server Test Case

A test case verifies the result for a scenario of use, or "case", of a target operation.

Decide on the action or component, known as the target, to be tested. Then decide on the scenarios to test. Scenarios could include single value, multiple values, zero values, expected exceptions. It helps to Consider the "contract" of the target to determine scenarios.

To write a server test case

  1. Create an server action naming it with the target and scenario.

    For example, testing an action ProcessStructure with large data values call the test Test_ProcessStructure_WithLargeData

  2. Add a parameter called ScriptRunId of type TestScriptRun Identifier. Pass the ScriptRunId from the REST API method to the action.
  3. Call TestCaseRun_Start to start the test case. It takes a TestScriptRun Identifier parameter and will associate results with the active script run.
  4. Set the Name as the name of the scenario. eg "With Large Data"
  5. Set the Target as the action or component being tested.
    eg ProcessStructure
  6. Store the TestCaseRunId returned from the TestCaseRun_Start action in a local variable
  7. Add an exception handler for AllExceptions which should call the Assert_ExceptionThrown action. This ensures an failure is recorded if an exception is thrown.
  8. Set up the data to be tested. This is the "Arrange" step.
  9. Call the action to test. This is the "Act" step.
  10. Use Assertion service actions from the KTest_CS module to check the results of the action. Create as many assertions as you need. This is the "Assert" step.
  11. Call TestCaseRun_End to complete the test case. If any assertions have failed, the test case will be set to failed.

Write as many test cases and call them from the REST API. This is your test script.

Expose a REST API to Run the Script

Expose a REST API for the Test Manager to call when the script runs.

To expose a REST API for the script

  1. In the module where you will write tests, navigate to Logic > Integrations > REST.
  2. Right-click on REST and select Expose REST API. Give it a name, eg UnitTests
  3. Under Security, set Internal Access Only to Yes.
  4. Set the Authentication property. Note this should match the Authentication Scheme set when you configure a script to call the REST API.
    1. For None, double check Internal Access Only is checked.
    2. For Basic, you will need to specify the username and password when you configure the script.
    3. For Custom, implement the OnAuthentication method. Call GetRequestHeader (From the HttpRequestHandler module) to get the "Authorization" header. Then call TestScriptRun_AuthenticateBearerToken() passing the value of the Authorization header.
  5. Right-click on the API and select Add REST API Method. Name the method, eg RunTests
  6. Set the HTTP Method to POST (otherwise you will get a MethodNotAllowed error).
  7. Add a parameter to the method named Request. Ensure Receive In is set to Body. Set its Data Type to structure TestScriptRequest from KTest_CS. Notice the structure has a single parameter ScriptRunId of type TestScriptRun identifier. This parameter is required to record test cases for the script run.
  8. In the method call a server action to run the unit tests.

Client Side Tests - Installation

The "K Test Client Actions Core" library contains all the client actions required to write unit tests for client actions. It depends on K Test Core.

Client unit tests are run on the server using Puppeteer. You can also run client tests manually by opening the page yourself.

To add the library:

  1. In Service Studio, click on Install from Forge.
  2. Find the "K Test Client Actions Core" library and install it.
  3. Open the module where you will write unit tests for client actions.
  4. Add dependencies from KTestClientActionsCore to your module.
    1. TestScript client actions
    2. TestCase client actions
    3. All the Assert actions you need for your unit tests.

Now write each set of unit tests as a test script.

How to Write a Client Test Script

The test script runs all the test cases for the script (see below for writing a test case).

To write a test script

  1. Create a page to run the test script, eg "RunTests". Create this page in a separate test application if you client actions are public.
  2. Limit permissions to users with the TestAdministrator role from KTest_CS.
  3. Add a client action to the page called RunTestScript() that returns a parameter Results of data type TestScriptBatchResult.
  4. Call RunTestScript() either from a button click or OnReady or both.
  5. In RunTestScript() call TestClientScriptRun_Start and pass the name and description of the test script. Assign the returned structure to the Results output parameter.
  6. Run all the test cases (see below) and assign the returned cases structure to Results.Cases.
  7. Call TestClientScriptRun_RecordBatch with the Results.
  8. Then call TestClientScriptRun_End passing the Results.ScriptRunId.
  9. Add an exception handler for AllExceptions and call TestClientScriptRun_Failed passing Results.ScriptRunId and the exception message. This will record the test script as failed.

Write as many test cases as you need. This is your test script.

Add the TestResultsBlock to your page to display the test results immediately. Otherwise view results of tests in the K Test Manager.

How to Write a Client Test Case

The test case verifies a particular "target", normally a client action, for a particular scenario.

To write a test case

  1. Create an action naming it with the target and scenario.
  2. For example, testing an action ProcessStructure with large data values call the test Test_ProcessStructure_WithLargeData
  3. Add a parameter called ScriptRunId of type TestScriptRun Identifier. Pass the ScriptRunId from RunTestScript action.
  4. Add an output parameter "Case" of type TestCaseResult.
  5. Call TestClientCaseRun_Start to start the test. Set the Name as the name of the scenario. eg "With Large Data". Set the Target as the action or component being tested. eg ProcessStructure
  6. Assign the returned structure to the output parameter "Case".
  7. Add an exception handler for AllExceptions which should call the TestClientCaseRun_Exception action. This ensures a failure is recorded if an exception is thrown. Although, if the exception is expected,
  8. use Assert_ExpectedException instead, and 
  9. add an Assertion that always fails after the exception should
  10. have been thrown.
  11. Set up the data to be tested. This is the "Arrange" step.
  12. Call the action to test. This is the "Act" step.
  13. Use Assert client actions from the KTestClientActionsCore module to check the results of the action. Create as many assertions as you need. This is the "Assert" step.
  14. Call TestClientCaseRun_End passing the "Case" output parameter to complete the test case. Assign the "Case" output parameter to the result of the TestClientCaseRun_End action.

Have a look at the demo app KTestClientActionsDemo to see an example of client unit tests. Notice it has a pattern for creating a unit test template for testing a particular client action. This pattern helps writing unit tests quickly for differing scenarios.


1.1.0

The K Test Core library provides a framework for configuring and running automated unit and integrations tests.

Use the K Test Manager forge component to provide a user interface for the to the manage test cases.

The forge components are separated as your code will depend on this component, whereas the K Test Manager only needs to be deployed to the dev environment.

How to Write a Test Case

A test case verifies the result for a scenario of use, or "case", of a target operation.

Decide on the action or component, known as the target, to be tested. Then decide on the scenarios to test. Scenarios could include single value, multiple values, zero values, expected exceptions. It helps to Consider the "contract" of the target to determine scenarios.

To write a test case

  1. Create an action naming it with the target and scenario.

    For example, testing an action ProcessStructure with large data values call the test Test_ProcessStructure_WithLargeData

  2. Add a parameter called ScriptRunId of type TestScriptRun Identifier. Pass the ScriptRunId from the REST API method to the action.
  3. Call TestCaseRun_Start to start the test case. It takes a TestScriptRun Identifier parameter and will associate results with the active script run.
  4. Set the Name as the name of the scenario. eg "With Large Data"
  5. Set the Target as the action or component being tested.
    eg ProcessStructure
  6. Store the TestCaseRunId returned from the TestCaseRun_Start action in a local variable
  7. Add an exception handler for AllExceptions which should call the Assert_ExceptionThrown action. This ensures an failure is recorded if an exception is thrown.
  8. Set up the data to be tested. This is the "Arrange" step.
  9. Call the action to test. This is the "Act" step.
  10. Use Assertion service actions from the KTest_CS module to check the results of the action. Create as many assertions as you need. This is the "Assert" step.
  11. Call TestCaseRun_End to complete the test case. If any assertions have failed, the test case will be set to failed.

Write as many test cases and call them from the REST API. This is your test script.

Expose a REST API to Run the Script

Expose a REST API for the Test Manager to call when the script runs.

To expose a REST API for the script

  1. In the module where you will write tests, navigate to Logic > Integrations > REST.
  2. Right-click on REST and select Expose REST API. Give it a name, eg UnitTests
  3. Under Security, set Internal Access Only to Yes.
  4. Set the Authentication property. Note this should match the Authentication Scheme set when you configure a script to call the REST API.
    1. For None, double check Internal Access Only is checked.
    2. For Basic, you will need to specify the username and password when you configure the script.
    3. For Custom, implement the OnAuthentication method. Call GetRequestHeader (From the HttpRequestHandler module) to get the "Authorization" header. Then call TestScriptRun_AuthenticateBearerToken() passing the value of the Authorization header.
  5. Right-click on the API and select Add REST API Method. Name the method, eg RunTests
  6. Set the HTTP Method to POST (otherwise you will get a MethodNotAllowed error).
  7. Add a parameter to the method named Request. Ensure Receive In is set to Body. Set its Data Type to structure TestScriptRequest from KTest_CS. Notice the structure has a single parameter ScriptRunId of type TestScriptRun identifier. This parameter is required to record test cases for the script run.
  8. In the method call a server action to run the unit tests.

1.0.6

The K Test Core library provides a framework for configuring and running automated unit and integrations tests.

Use the K Test Manager forge component to provide a user interface for the to the manage test cases.

The forge components are separated as your code will depend on this component, whereas the K Test Manager only needs to be deployed to the dev environment.

How to Write a Test Case

A test case verifies the result for a scenario of use, or "case", of a target operation.

Decide on the action or component, known as the target, to be tested. Then decide on the scenarios to test. Scenarios could include single value, multiple values, zero values, expected exceptions. It helps to Consider the "contract" of the target to determine scenarios.

To write a test case

  1. Create an action naming it with the target and scenario.

    For example, testing an action ProcessStructure with large data values call the test Test_ProcessStructure_WithLargeData

  2. Add a parameter called ScriptRunId of type TestScriptRun Identifier. Pass the ScriptRunId from the REST API method to the action.
  3. Call TestCaseRun_Start to start the test case. It takes a TestScriptRun Identifier parameter and will associate results with the active script run.
  4. Set the Name as the name of the scenario. eg "With Large Data"
  5. Set the Target as the action or component being tested.
    eg ProcessStructure
  6. Store the TestCaseRunId returned from the TestCaseRun_Start action in a local variable
  7. Add an exception handler for AllExceptions which should call the Assert_ExceptionThrown action. This ensures an failure is recorded if an exception is thrown.
  8. Set up the data to be tested. This is the "Arrange" step.
  9. Call the action to test. This is the "Act" step.
  10. Use Assertion service actions from the KTest_CS module to check the results of the action. Create as many assertions as you need. This is the "Assert" step.
  11. Call TestCaseRun_End to complete the test case. If any assertions have failed, the test case will be set to failed.

Write as many test cases and call them from the REST API. This is your test script.

Expose a REST API to Run the Script

Expose a REST API for the Test Manager to call when the script runs.

To expose a REST API for the script

  1. In the module where you will write tests, navigate to Logic > Integrations > REST.
  2. Right-click on REST and select Expose REST API. Give it a name, eg UnitTests
  3. Under Security, set Internal Access Only to Yes.
  4. Set the Authentication property. Note this should match the Authentication Scheme set when you configure a script to call the REST API.
    1. For None, double check Internal Access Only is checked.
    2. For Basic, you will need to specify the username and password when you configure the script.
    3. For Custom, implement the OnAuthentication method. Call GetRequestHeader (From the HttpRequestHandler module) to get the "Authorization" header. Then call TestScriptRun_AuthenticateBearerToken() passing the value of the Authorization header.
  5. Right-click on the API and select Add REST API Method. Name the method, eg RunTests
  6. Set the HTTP Method to POST (otherwise you will get a MethodNotAllowed error).
  7. Add a parameter to the method named Request. Ensure Receive In is set to Body. Set its Data Type to structure TestScriptRequest from KTest_CS. Notice the structure has a single parameter ScriptRunId of type TestScriptRun identifier. This parameter is required to record test cases for the script run.
  8. In the method call a server action to run the unit tests.

1.0.5
The K Test Core library provides a framework for configuring and running automated unit and integrations tests.

Use the K Test Manager forge component to provide a user interface for the to the manage test cases.

The forge components are separated as your code will depend on this component, whereas the K Test Manager only needs to be deployed to the dev environment.

How to Write a Test Case

A test case verifies the result for a scenario of use, or "case", of a target operation.

Decide on the action or component, known as the target, to be tested. Then decide on the scenarios to test. Scenarios could include single value, multiple values, zero values, expected exceptions. It helps to Consider the "contract" of the target to determine scenarios.

To write a test case

  1. Create an action naming it with the target and scenario.
    For example, testing an action ProcessStructure with large data values call the test Test_ProcessStructure_WithLargeData
  2. Add a parameter called ScriptRunId of type TestScriptRun Identifier. Pass the ScriptRunId from the REST API method to the action.
  3. Call TestCaseRun_Start to start the test case. It takes a TestScriptRun Identifier parameter and will associate results with the active script run.
  4. Set the Name as the name of the scenario. eg "With Large Data"
  5. Set the Target as the action or component being tested.
    eg ProcessStructure
  6. Store the TestCaseRunId returned from the TestCaseRun_Start action in a local variable
  7. Add an exception handler for AllExceptions which should call the Assert_ExceptionThrown action. This ensures an failure is recorded if an exception is thrown.
  8. Set up the data to be tested. This is the "Arrange" step.
  9. Call the action to test. This is the "Act" step.
  10. Use Assertion service actions from the KTest_CS module to check the results of the action. Create as many assertions as you need. This is the "Assert" step.
  11. Call TestCaseRun_End to complete the test case. If any assertions have failed, the test case will be set to failed.

Write as many test cases and call them from the REST API. This is your test script.

Expose a REST API to Run the Script

Expose a REST API for the Test Manager to call when the script runs.

To expose a REST API for the script

  1. In the module where you will write tests, navigate to Logic > Integrations > REST.
  2. Right-click on REST and select Expose REST API. Give it a name, eg UnitTests
  3. Under Security, set Internal Access Only to Yes.
  4. Set the Authentication property. Note this should match the Authentication Scheme set when you configure a script to call the REST API.
    1. For None, double check Internal Access Only is checked.
    2. For Basic, you will need to specify the username and password when you configure the script.
    3. For Custom, implement the OnAuthentication method. Call GetRequestHeader (From the HttpRequestHandler module) to get the "Authorization" header. Then call TestScriptRun_AuthenticateBearerToken() passing the value of the Authorization header.
  5. Right-click on the API and select Add REST API Method. Name the method, eg RunTests
  6. Set the HTTP Method to POST (otherwise you will get a MethodNotAllowed error).
  7. Add a parameter to the method named Request. Ensure Receive In is set to Body. Set its Data Type to structure TestScriptRequest from KTest_CS. Notice the structure has a single parameter ScriptRunId of type TestScriptRun identifier. This parameter is required to record test cases for the script run.
  8. In the method call a server action to run the unit tests.

1.0.4
The K Test Core library provides a framework for configuring and running automated unit and integrations tests.

Use the K Test Manager forge component to provide a user interface for the to the manage test cases.

The forge components are separated as your code will depend on this component, whereas the K Test Manager only needs to be deployed to the dev environment.

How to Write a Test Case

A test case verifies the result for a scenario of use, or "case", of a target operation.

Decide on the action or component, known as the target, to be tested. Then decide on the scenarios to test. Scenarios could include single value, multiple values, zero values, expected exceptions. It helps to Consider the "contract" of the target to determine scenarios.

To write a test case

  1. Create an action naming it with the target and scenario.
    For example, testing an action ProcessStructure with large data values call the test Test_ProcessStructure_WithLargeData
  2. Add a parameter called ScriptRunId of type TestScriptRun Identifier. Pass the ScriptRunId from the REST API method to the action.
  3. Call TestCaseRun_Start to start the test case. It takes a TestScriptRun Identifier parameter and will associate results with the active script run.
  4. Set the Name as the name of the scenario. eg "With Large Data"
  5. Set the Target as the action or component being tested.
    eg ProcessStructure
  6. Store the TestCaseRunId returned from the TestCaseRun_Start action in a local variable
  7. Add an exception handler for AllExceptions which should call the Assert_ExceptionThrown action. This ensures an failure is recorded if an exception is thrown.
  8. Set up the data to be tested. This is the "Arrange" step.
  9. Call the action to test. This is the "Act" step.
  10. Use Assertion service actions from the KTest_CS module to check the results of the action. Create as many assertions as you need. This is the "Assert" step.
  11. Call TestCaseRun_End to complete the test case. If any assertions have failed, the test case will be set to failed.

Write as many test cases and call them from the REST API. This is your test script.

Expose a REST API to Run the Script

Expose a REST API for the Test Manager to call when the script runs.

To expose a REST API for the script

  1. In the module where you will write tests, navigate to Logic > Integrations > REST.
  2. Right-click on REST and select Expose REST API. Give it a name, eg UnitTests
  3. Under Security, set Internal Access Only to Yes.
  4. Set the Authentication property. Note this should match the Authentication Scheme set when you configure a script to call the REST API.
    1. For None, double check Internal Access Only is checked.
    2. For Basic, you will need to specify the username and password when you configure the script.
    3. For Custom, implement the OnAuthentication method. Call GetRequestHeader (From the HttpRequestHandler module) to get the "Authorization" header. Then call TestScriptRun_AuthenticateBearerToken() passing the value of the Authorization header.
  5. Right-click on the API and select Add REST API Method. Name the method, eg RunTests
  6. Set the HTTP Method to POST (otherwise you will get a MethodNotAllowed error).
  7. Add a parameter to the method named Request. Ensure Receive In is set to Body. Set its Data Type to structure TestScriptRequest from KTest_CS. Notice the structure has a single parameter ScriptRunId of type TestScriptRun identifier. This parameter is required to record test cases for the script run.
  8. In the method call a server action to run the unit tests.

1.0.3

The K Test Core library provides a framework for configuring and running automated unit and integrations tests.

Use the K Test Manager forge component to provide a user interface for the to the manage test cases.

The forge components are separated as your code will depend on this component, whereas the K Test Manager only needs to be deployed to the dev environment.

How to Write a Test Case

A test case verifies the result for a scenario of use, or "case", of a target operation.

Decide on the action or component, known as the target, to be tested. Then decide on the scenarios to test. Scenarios could include single value, multiple values, zero values, expected exceptions. It helps to Consider the "contract" of the target to determine scenarios.

To write a test case

  1. Create an action naming it with the target and scenario.
    For example, testing an action ProcessStructure with large data values call the test Test_ProcessStructure_WithLargeData
  2. Add a parameter called ScriptRunId of type TestScriptRun Identifier. Pass the ScriptRunId from the REST API method to the action.
  3. Call TestCaseRun_Start to start the test case. It takes a TestScriptRun Identifier parameter and will associate results with the active script run.
  4. Set the Name as the name of the scenario. eg "With Large Data"
  5. Set the Target as the action or component being tested.
    eg ProcessStructure
  6. Store the TestCaseRunId returned from the TestCaseRun_Start action in a local variable
  7. Add an exception handler for AllExceptions which should call the Assert_ExceptionThrown action. This ensures an failure is recorded if an exception is thrown.
  8. Set up the data to be tested. This is the "Arrange" step.
  9. Call the action to test. This is the "Act" step.
  10. Use Assertion service actions from the KTest_CS module to check the results of the action. Create as many assertions as you need. This is the "Assert" step.
  11. Call TestCaseRun_End to complete the test case. If any assertions have failed, the test case will be set to failed.

Write as many test cases and call them from the REST API. This is your test script.

Expose a REST API to Run the Script

Expose a REST API for the Test Manager to call when the script runs.

To expose a REST API for the script

  1. In the module where you will write tests, navigate to Logic > Integrations > REST.
  2. Right-click on REST and select Expose REST API. Give it a name, eg UnitTests
  3. Under Security, set Internal Access Only to Yes.
  4. Set the Authentication property. Note this should match the Authentication Scheme set when you configure a script to call the REST API.
    1. For None, double check Internal Access Only is checked.
    2. For Basic, you will need to specify the username and password when you configure the script.
    3. For Custom, implement the OnAuthentication method. Call GetRequestHeader (From the HttpRequestHandler module) to get the "Authorization" header. Then call TestScriptRun_AuthenticateBearerToken() passing the value of the Authorization header.
  5. Right-click on the API and select Add REST API Method. Name the method, eg RunTests
  6. Set the HTTP Method to POST (otherwise you will get a MethodNotAllowed error).
  7. Add a parameter to the method named Request. Ensure Receive In is set to Body. Set its Data Type to structure TestScriptRequest from KTest_CS. Notice the structure has a single parameter ScriptRunId of type TestScriptRun identifier. This parameter is required to record test cases for the script run.
  8. In the method call a server action to run the unit tests.

1.0.2

The K Test Core library provides a framework for configuring and running automated unit and integrations tests.

Use the K Test Manager forge component to provide a user interface for the to the manage test cases.

The forge components are separated as your code will depend on this component, whereas the K Test Manager only needs to be deployed to the dev environment.

How to Write a Test Case

A test case verifies the result for a scenario of use, or "case", of a target operation.

Decide on the action or component, known as the target, to be tested. Then decide on the scenarios to test. Scenarios could include single value, multiple values, zero values, expected exceptions. It helps to Consider the "contract" of the target to determine scenarios.

To write a test case

  1. Create an action naming it with the target and scenario.
    For example, testing an action ProcessStructure with large data values call the test Test_ProcessStructure_WithLargeData
  2. Add a parameter called ScriptRunId of type TestScriptRun Identifier. Pass the ScriptRunId from the REST API method to the action.
  3. Call TestCaseRun_Start to start the test case. It takes a TestScriptRun Identifier parameter and will associate results with the active script run.
  4. Set the Name as the name of the scenario. eg "With Large Data"
  5. Set the Target as the action or component being tested.
    eg ProcessStructure
  6. Store the TestCaseRunId returned from the TestCaseRun_Start action in a local variable
  7. Add an exception handler for AllExceptions which should call the Assert_ExceptionThrown action. This ensures an failure is recorded if an exception is thrown.
  8. Set up the data to be tested. This is the "Arrange" step.
  9. Call the action to test. This is the "Act" step.
  10. Use Assertion service actions from the KTest_CS module to check the results of the action. Create as many assertions as you need. This is the "Assert" step.
  11. Call TestCaseRun_End to complete the test case. If any assertions have failed, the test case will be set to failed.

Write as many test cases and call them from the REST API. This is your test script.

Expose a REST API to Run the Script

Expose a REST API for the Test Manager to call when the script runs.

To expose a REST API for the script

  1. In the module where you will write tests, navigate to Logic > Integrations > REST.
  2. Right-click on REST and select Expose REST API. Give it a name, eg UnitTests
  3. Under Security, set Internal Access Only to Yes.
  4. Set the Authentication property. Note this should match the Authentication Scheme set when you configure a script to call the REST API.
    1. For None, double check Internal Access Only is checked.
    2. For Basic, you will need to specify the username and password when you configure the script.
    3. For Custom, implement the OnAuthentication method. Call GetRequestHeader (From the HttpRequestHandler module) to get the "Authorization" header. Then call TestScriptRun_AuthenticateBearerToken() passing the value of the Authorization header.
  5. Right-click on the API and select Add REST API Method. Name the method, eg RunTests
  6. Set the HTTP Method to POST (otherwise you will get a MethodNotAllowed error).
  7. Add a parameter to the method named Request. Ensure Receive In is set to Body. Set its Data Type to structure TestScriptRequest from KTest_CS. Notice the structure has a single parameter ScriptRunId of type TestScriptRun identifier. This parameter is required to record test cases for the script run.
  8. In the method call a server action to run the unit tests.

1.0.1

The K Test Core library provides a framework for configuring and running automated unit and integrations tests.

Use the K Test Manager forge component to provide a user interface for the to the manage test cases.

The forge components are separated as your code will depend on this component, whereas the K Test Manager only needs to be deployed to the dev environment.

How to Write a Test Case

A test case verifies the result for a scenario of use, or "case", of a target operation.

Decide on the action or component, known as the target, to be tested. Then decide on the scenarios to test. Scenarios could include single value, multiple values, zero values, expected exceptions. It helps to Consider the "contract" of the target to determine scenarios.

To write a test case

  1. Create an action naming it with the target and scenario.
    For example, testing an action ProcessStructure with large data values call the test Test_ProcessStructure_WithLargeData
  2. Add a parameter called ScriptRunId of type TestScriptRun Identifier. Pass the ScriptRunId from the REST API method to the action.
  3. Call TestCaseRun_Start to start the test case. It takes a TestScriptRun Identifier parameter and will associate results with the active script run.
  4. Set the Name as the name of the scenario. eg "With Large Data"
  5. Set the Target as the action or component being tested.
    eg ProcessStructure
  6. Store the TestCaseRunId returned from the TestCaseRun_Start action in a local variable
  7. Add an exception handler for AllExceptions which should call the Assert_ExceptionThrown action. This ensures an failure is recorded if an exception is thrown.
  8. Set up the data to be tested. This is the "Arrange" step.
  9. Call the action to test. This is the "Act" step.
  10. Use Assertion service actions from the KTest_CS module to check the results of the action. Create as many assertions as you need. This is the "Assert" step.
  11. Call TestCaseRun_End to complete the test case. If any assertions have failed, the test case will be set to failed.

Write as many test cases and call them from the REST API. This is your test script.

Expose a REST API to Run the Script

Expose a REST API for the Test Manager to call when the script runs.

To expose a REST API for the script

  1. In the module where you will write tests, navigate to Logic > Integrations > REST.
  2. Right-click on REST and select Expose REST API. Give it a name, eg UnitTests
  3. Under Security, set Internal Access Only to Yes.
  4. Set the Authentication property. Note this should match the Authentication Scheme set when you configure a script to call the REST API.
    1. For None, double check Internal Access Only is checked.
    2. For Basic, you will need to specify the username and password when you configure the script.
    3. For Custom, implement the OnAuthentication method. Call GetRequestHeader (From the HttpRequestHandler module) to get the "Authorization" header. Then call TestScriptRun_AuthenticateBearerToken() passing the value of the Authorization header.
  5. Right-click on the API and select Add REST API Method. Name the method, eg RunTests
  6. Set the HTTP Method to POST (otherwise you will get a MethodNotAllowed error).
  7. Add a parameter to the method named Request. Ensure Receive In is set to Body. Set its Data Type to structure TestScriptRequest from KTest_CS. Notice the structure has a single parameter ScriptRunId of type TestScriptRun identifier. This parameter is required to record test cases for the script run.
  8. In the method call a server action to run the unit tests.

1.0.0

The K Test Core library provides a framework for configuring and running automated unit and integrations tests.

Use the K Test Manager forge component to provide a user interface for the to the manage test cases.

The forge components are separated as your code will depend on this component, whereas the K Test Manager only needs to be deployed to the dev environment.

How to Write a Test Case

A test case verifies the result for a scenario of use, or "case", of a target operation.

Decide on the action or component, known as the target, to be tested. Then decide on the scenarios to test. Scenarios could include single value, multiple values, zero values, expected exceptions. It helps to Consider the "contract" of the target to determine scenarios.

To write a test case

  1. Create an action naming it with the target and scenario.
    For example, testing an action ProcessStructure with large data values call the test Test_ProcessStructure_WithLargeData
  2. Add a parameter called ScriptRunId of type TestScriptRun Identifier. Pass the ScriptRunId from the REST API method to the action.
  3. Call TestCaseRun_Start to start the test case. It takes a TestScriptRun Identifier parameter and will associate results with the active script run.
  4. Set the Name as the name of the scenario. eg "With Large Data"
  5. Set the Target as the action or component being tested.
    eg ProcessStructure
  6. Store the TestCaseRunId returned from the TestCaseRun_Start action in a local variable
  7. Add an exception handler for AllExceptions which should call the Assert_ExceptionThrown action. This ensures an failure is recorded if an exception is thrown.
  8. Set up the data to be tested. This is the "Arrange" step.
  9. Call the action to test. This is the "Act" step.
  10. Use Assertion service actions from the KTest_CS module to check the results of the action. Create as many assertions as you need. This is the "Assert" step.
  11. Call TestCaseRun_End to complete the test case. If any assertions have failed, the test case will be set to faield.

Write as many test cases and call them from the REST API. This is your test script.

Expose a REST API to Run the Script

Expose a REST API for the Test Manager to call when the script runs.

To expose a REST API for the script

  1. In the module where you will write tests, navigate to Logic > Integrations > REST.
  2. Right-click on REST and select Expose REST API. Give it a name, eg UnitTests
  3. Under Security, set Internal Access Only to Yes.
  4. Set the Authentication property. Note this should match the Authentication Scheme set when you configure a script to call the REST API.
    1. For None, double check Internal Access Only is checked.
    2. For Basic, you will need to specify the username and password when you configure the script.
    3. For Custom, implement the OnAuthentication method. Call GetRequestHeader (From the HttpRequestHandler module) to get the "Authorization" header. Then call TestScriptRun_AuthenticateBearerToken() passing the value of the Authorization header.
  5. Right-click on the API and select Add REST API Method. Name the method, eg RunTests
  6. Set the HTTP Method to POST (otherwise you will get a MethodNotAllowed error).
  7. Add a parameter to the method named Request. Ensure Receive In is set to Body. Set its Data Type to structure TestScriptRequest from KTest_CS. Notice the structure has a single parameter ScriptRunId of type TestScriptRun identifier. This parameter is required to record test cases for the script run.
  8. In the method call a server action to run the unit tests.