k-test-manager
Reactive icon

K Test Manager

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

K Test Manager

Documentation
1.2.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. Select the target layer depending on whether the test will verify server actions or client actions
  5. The Base URL will default to the URL of the current environment.
  6. For the Relative URL, enter the URL of the test script API.

    eg /KTest_SampleTest/rest/UnitTests/RunTests

  7. 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.
  8. Click save.

The script will be available to be run.

Additional Information for Client Test Scripts

If it is a client-side test, additional details will be required such as the screen height and width, CSS selectors for screen elements and the timeout.

Consider whether your client test requires a parameter to run the test, or if it runs from the OnReady screen event.



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

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.

Additional Information for Client Test Scripts

If it is a client-side test, additional details will be required such as the screen height and width, CSS selectors for screen elements and the timeout.

Consider whether your client test requires a parameter to run the test, or if it runs from the OnReady screen event.

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 Server Test Case

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

Decide on the server 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.

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

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

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