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
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
Click Save.
Note the Run Tests button will not be available until the suite has test scripts.
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
For the Relative URL, enter the URL of the test script API.
eg /KTest_SampleTest/rest/UnitTests/RunTests
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
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
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
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:
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
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
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.
How to Expose a Test Script API
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.
Create an action naming it with the target and scenario.
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.
How to Write a Test Case