Give us feedback
k-test-manager
Reactive icon

K Test Manager

Stable version 1.0.5 (Compatible with OutSystems 11)
Uploaded on 25 Jan by 
5.0
 (1 rating)
k-test-manager

K Test Manager

Documentation
1.0.5

Using the K Test Manager

The K TEST MANAGER will run suites of tests written in code, or "unit tests", and helps monitor the results.

Only test suites and test scripts must be configured. Test cases are automatically added to a test script when the test script runs.

The structure of tests is

  • A test suite consists of multiple test scripts.
  • A test script is run via an authenticated REST API call.
  • A test script runs one or more test cases. 
  • A test case verifies the result for a scenario of use, or "case", of a target operation.
  • Within the test case, assertions check individual properties of the target operation's result.

The test suite may be run as a whole or test scripts may be run individually. To run test cases individually, expose a separate script API call to run a particular test case.

How to Configure a Test Suite

A test suite is simply a container for one or more test scripts.

To add a test suite

  1. Navigate to Test Suites via the main menu.
  2. Click on Add Test Suite
  3. Enter the name and, optionally, a description for the test suite. Only active scripts will be scheduled to run.
  4. Select a schedule to automatically run the test suite. Select from Daily, Weekly or Monthly. Different options will show depeneding on the selection.
  5. Enter the times of day when the test should run. Times are limited to run tests on the hour. Multiple times may be configured.
  6. Click Save.
    Note the Run Tests button will not be available until the suite has test scripts.
  7. Click on Edit test suite to change the test suite or the schedule.

How to Configure a Test Script

A test script configures a REST API that will run test cases.

Test cases will be added automatically when the test script runs. They do not need to be manually configured.

To add a test script

  1. Navigate to a test suite.
  2. Click on the Add Script button.
  3. Enter the name and, optionally, a description. 
  4. The Base URL will default to the URL of the current environment.
  5. For the Relative URL, enter the URL of the test script API.
    eg /KTest_SampleTest/rest/UnitTests/RunTests
  6. Select the Authentication Scheme
    1. None No authentication. Ensure the REST API is set to Internal Access Only.
    2. Basic Username/password authentication. The test will run as the user with the specified username.
    3. Bearer When the test script runs, a temporary bearer token will be generated. Set authentication for the REST API to Custom. In the OnAuthentication action, call GetRequestHeader() from the HTTPRequestHandler module with HeaderName "Authorization". Then pass the value to the TestScriptRun_AuthenticateBearerToken() action from KTest_CS.
  7. Click save.

The script will be available to be run.

How to Expose a Test Script API

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.

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 a 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 Assert 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 are required and call them from the REST API. This is your test script.

Now you can configure and run the test script.


1.0.4

Using the K Test Manager

The K TEST MANAGER will run suites of tests written in code, or "unit tests", and helps monitor the results.

Only test suites and test scripts must be configured. Test cases are automatically added to a test script when the test script runs.

The structure of tests is

  • A test suite consists of multiple test scripts.
  • A test script is run via an authenticated REST API call.
  • A test script runs one or more test cases. 
  • A test case verifies the result for a scenario of use, or "case", of a target operation.
  • Within the test case, assertions check individual properties of the target operation's result.

The test suite may be run as a whole or test scripts may be run individually. To run test cases individually, expose a separate script API call to run a particular test case.

How to Configure a Test Suite

A test suite is simply a container for one or more test scripts.

To add a test suite

  1. Navigate to Test Suites via the main menu.
  2. Click on Add Test Suite
  3. Enter the name and, optionally, a description for the test suite. Only active scripts will be scheduled to run.
  4. Select a schedule to automatically run the test suite. Select from Daily, Weekly or Monthly. Different options will show depeneding on the selection.
  5. Enter the times of day when the test should run. Times are limited to run tests on the hour. Multiple times may be configured.
  6. Click Save.
    Note the Run Tests button will not be available until the suite has test scripts.
  7. Click on Edit test suite to change the test suite or the schedule.

How to Configure a Test Script

A test script configures a REST API that will run test cases.

Test cases will be added automatically when the test script runs. They do not need to be manually configured.

To add a test script

  1. Navigate to a test suite.
  2. Click on the Add Script button.
  3. Enter the name and, optionally, a description. 
  4. The Base URL will default to the URL of the current environment.
  5. For the Relative URL, enter the URL of the test script API.
    eg /KTest_SampleTest/rest/UnitTests/RunTests
  6. Select the Authentication Scheme
    1. None No authentication. Ensure the REST API is set to Internal Access Only.
    2. Basic Username/password authentication. The test will run as the user with the specified username.
    3. Bearer When the test script runs, a temporary bearer token will be generated. Set authentication for the REST API to Custom. In the OnAuthentication action, call GetRequestHeader() from the HTTPRequestHandler module with HeaderName "Authorization". Then pass the value to the TestScriptRun_AuthenticateBearerToken() action from KTest_CS.
  7. Click save.

The script will be available to be run.

How to Expose a Test Script API

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.

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 a 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 Assert 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 are required and call them from the REST API. This is your test script.

Now you can configure and run the test script.


1.0.3

Using the K Test Manager

The K TEST MANAGER will run suites of tests written in code, or "unit tests", and helps monitor the results.

Only test suites and test scripts must be configured. Test cases are automatically added to a test script when the test script runs.

The structure of tests is

  • A test suite consists of multiple test scripts.
  • A test script is run via an authenticated REST API call.
  • A test script runs one or more test cases. 
  • A test case verifies the result for a scenario of use, or "case", of a target operation.
  • Within the test case, assertions check individual properties of the target operation's result.

The test suite may be run as a whole or test scripts may be run individually. To run test cases individually, expose a separate script API call to run a particular test case.

How to Configure a Test Suite

A test suite is simply a container for one or more test scripts.

To add a test suite

  1. Navigate to Test Suites via the main menu.
  2. Click on Add Test Suite
  3. Enter the name and, optionally, a description for the test suite. Only active scripts will be scheduled to run.
  4. Select a schedule to automatically run the test suite. Select from Daily, Weekly or Monthly. Different options will show depeneding on the selection.
  5. Enter the times of day when the test should run. Times are limited to run tests on the hour. Multiple times may be configured.
  6. Click Save.
    Note the Run Tests button will not be available until the suite has test scripts.
  7. Click on Edit test suite to change the test suite or the schedule.

How to Configure a Test Script

A test script configures a REST API that will run test cases.

Test cases will be added automatically when the test script runs. They do not need to be manually configured.

To add a test script

  1. Navigate to a test suite.
  2. Click on the Add Script button.
  3. Enter the name and, optionally, a description. 
  4. The Base URL will default to the URL of the current environment.
  5. For the Relative URL, enter the URL of the test script API.
    eg /KTest_SampleTest/rest/UnitTests/RunTests
  6. Select the Authentication Scheme
    1. None No authentication. Ensure the REST API is set to Internal Access Only.
    2. Basic Username/password authentication. The test will run as the user with the specified username.
    3. Bearer When the test script runs, a temporary bearer token will be generated. Set authentication for the REST API to Custom. In the OnAuthentication action, call GetRequestHeader() from the HTTPRequestHandler module with HeaderName "Authorization". Then pass the value to the TestScriptRun_AuthenticateBearerToken() action from KTest_CS.
  7. Click save.

The script will be available to be run.

How to Expose a Test Script API

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.

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 a 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 Assert 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 are required and call them from the REST API. This is your test script.

Now you can configure and run the test script.


1.0.2

Using the K Test Manager

The K TEST MANAGER will run suites of tests written in code, or "unit tests", and helps monitor the results.

Only test suites and test scripts must be configured. Test cases are automatically added to a test script when the test script runs.

The structure of tests is

  • A test suite consists of multiple test scripts.
  • A test script is run via an authenticated REST API call.
  • A test script runs one or more test cases. 
  • A test case verifies the result for a scenario of use, or "case", of a target operation.
  • Within the test case, assertions check individual properties of the target operation's result.

The test suite may be run as a whole or test scripts may be run individually. To run test cases individually, expose a separate script API call to run a particular test case.

How to Configure a Test Suite

A test suite is simply a container for one or more test scripts.

To add a test suite

  1. Navigate to Test Suites via the main menu.
  2. Click on Add Test Suite
  3. Enter the name and, optionally, a description for the test suite. Only active scripts will be scheduled to run.
  4. Select a schedule to automatically run the test suite. Select from Daily, Weekly or Monthly. Different options will show depeneding on the selection.
  5. Enter the times of day when the test should run. Times are limited to run tests on the hour. Multiple times may be configured.
  6. Click Save.
    Note the Run Tests button will not be available until the suite has test scripts.
  7. Click on Edit test suite to change the test suite or the schedule.

How to Configure a Test Script

A test script configures a REST API that will run test cases.

Test cases will be added automatically when the test script runs. They do not need to be manually configured.

To add a test script

  1. Navigate to a test suite.
  2. Click on the Add Script button.
  3. Enter the name and, optionally, a description. 
  4. The Base URL will default to the URL of the current environment.
  5. For the Relative URL, enter the URL of the test script API.
    eg /KTest_SampleTest/rest/UnitTests/RunTests
  6. Select the Authentication Scheme
    1. None No authentication. Ensure the REST API is set to Internal Access Only.
    2. Basic Username/password authentication. The test will run as the user with the specified username.
    3. Bearer When the test script runs, a temporary bearer token will be generated. Set authentication for the REST API to Custom. In the OnAuthentication action, call GetRequestHeader() from the HTTPRequestHandler module with HeaderName "Authorization". Then pass the value to the TestScriptRun_AuthenticateBearerToken() action from KTest_CS.
  7. Click save.

The script will be available to be run.

How to Expose a Test Script API

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.

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 a 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 Assert 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 are required and call them from the REST API. This is your test script.

Now you can configure and run the test script.


1.0.1

Using the K Test Manager

The K TEST MANAGER will run suites of tests written in code, or "unit tests", and helps monitor the results.

Only test suites and test scripts must be configured. Test cases are automatically added to a test script when the test script runs.

The structure of tests is

  • A test suite consists of multiple test scripts.
  • A test script is run via an authenticated REST API call.
  • A test script runs one or more test cases. 
  • A test case verifies the result for a scenario of use, or "case", of a target operation.
  • Within the test case, assertions check individual properties of the target operation's result.

The test suite may be run as a whole or test scripts may be run individually. To run test cases individually, expose a separate script API call to run a particular test case.

How to Configure a Test Suite

A test suite is simply a container for one or more test scripts.

To add a test suite

  1. Navigate to Test Suites via the main menu.
  2. Click on Add Test Suite
  3. Enter the name and, optionally, a description for the test suite. Only active scripts will be scheduled to run.
  4. Select a schedule to automatically run the test suite. Select from Daily, Weekly or Monthly. Different options will show depeneding on the selection.
  5. Enter the times of day when the test should run. Times are limited to run tests on the hour. Multiple times may be configured.
  6. Click Save.
    Note the Run Tests button will not be available until the suite has test scripts.
  7. Click on Edit test suite to change the test suite or the schedule.

How to Configure a Test Script

A test script configures a REST API that will run test cases.

Test cases will be added automatically when the test script runs. They do not need to be manually configured.

To add a test script

  1. Navigate to a test suite.
  2. Click on the Add Script button.
  3. Enter the name and, optionally, a description. 
  4. The Base URL will default to the URL of the current environment.
  5. For the Relative URL, enter the URL of the test script API.
    eg /KTest_SampleTest/rest/UnitTests/RunTests
  6. Select the Authentication Scheme
    1. None No authentication. Ensure the REST API is set to Internal Access Only.
    2. Basic Username/password authentication. The test will run as the user with the specified username.
    3. Bearer When the test script runs, a temporary bearer token will be generated. Set authentication for the REST API to Custom. In the OnAuthentication action, call GetRequestHeader() from the HTTPRequestHandler module with HeaderName "Authorization". Then pass the value to the TestScriptRun_AuthenticateBearerToken() action from KTest_CS.
  7. Click save.

The script will be available to be run.

How to Expose a Test Script API

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.

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 a 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 Assert 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 are required and call them from the REST API. This is your test script.

Now you can configure and run the test script.


1.0.0

Using the K Test Manager

The K TEST MANAGER will run suites of tests written in code, or "unit tests", and helps monitor the results.

Only test suites and test scripts must be configured. Test cases are automatically added to a test script when the test script runs.

The structure of tests is

  • A test suite consists of multiple test scripts.
  • A test script is run via an authenticated REST API call.
  • A test script runs one or many test cases. 
  • A test case verifies the result for a scenario of use, or "case", of a target operation.
  • Within the test case, assertions check individual properties of the target operation's result.

The test suite may be run as a whole or test scripts may be run individually. To run test cases individually, expose a separate script API call to run a particular test case.

How to Configure a Test Suite

A test suite is simply a container for one or more test scripts.

To add a test suite

  1. Navigate to Test Suites via the main menu.
  2. Click on Add Test Suite
  3. Enter the name and, optionally, a description for the test suite. 
  4. Click save.
    Note the Run Tests button will not be available until the suite has test scripts.
  5. Click on Edit test suite to change the name or description.

How to Configure a Test Script

A test script configures a REST API that will run test cases.

Test cases will be added automatically when the test script runs. They do not need to be manually configured.

To add a test script

  1. Navigate to a test suite.
  2. Click on the Add Script button.
  3. Enter the name and, optionally, a description. 
  4. The Base URL will default to the URL of the current environment.
  5. For the Relative URL, enter the URL of the test script API.
    eg /KTest_SampleTest/rest/UnitTests/RunTests
  6. Select the Authentication Scheme
    1. None No authentication. Ensure the REST API is set to Internal Access Only.
    2. Basic Username/password authentication. The test will run as the user with the specified username.
    3. Bearer When the test script runs, a temporary bearer token will be generated. Set authentication for the REST API to Custom. In the OnAuthentication action, call GetRequestHeader() from the HTTPRequestHandler module with HeaderName "Authorization". Then pass the value to the TestScriptRun_AuthenticateBearerToken() action from KTest_CS.
  7. Click save.

The script will be available to be run.

How to Expose a Test Script API

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.

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 Assert 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.

Now you can configure and run the test script.