k-test-client-actions-core
Reactive icon

K Test Client Actions Core

Stable version 1.0.6 (Compatible with OutSystems 11)
Uploaded
 on 10 Oct
 by 
5.0
 (1 rating)
k-test-client-actions-core

K Test Client Actions Core

Documentation
1.0.6

The K Test Client Actions Core library provides a framework for configuring and running automated unit tests on client actions. There is also a block, TestResultsBlock, for displaying results of client action unit tests.

Use the K Test Manager forge component to provide a user interface to the manage test scripts and review results.

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

First write a client test script. Then write test cases to verify client actions in multiple scenarios.

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"

  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.

    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 RunTestScript action.
  3. Add an output parameter "Case" of type TestCaseResult.
  4. 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
  5. Assign the returned structure to the output parameter "Case".
  6. 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,
    use Assert_ExpectedException instead, and
    add an Assertion that always fails after the exception should
    have been thrown.
  7. Set up the data to be tested. This is the "Arrange" step.
  8. Call the action to test. This is the "Act" step.
  9. 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.
  10. 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.0.2

The K Test Client Actions Core library provides a framework for configuring and running automated unit tests on client actions. There is also a block, TestResultsBlock, for displaying results of client action unit tests.

Use the K Test Manager forge component to provide a user interface to the manage test scripts and review results.

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

First write a client test script. Then write test cases to verify client actions in multiple scenarios.

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"
  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.
    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 RunTestScript action.
  3. Add an output parameter "Case" of type TestCaseResult.
  4. 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
  5. Assign the returned structure to the output parameter "Case".
  6. 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,
    use Assert_ExpectedException instead, and
    add an Assertion that always fails after the exception should
    have been thrown.
  7. Set up the data to be tested. This is the "Arrange" step.
  8. Call the action to test. This is the "Act" step.
  9. 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.
  10. 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.0.1

The K Test Client Actions Core library provides a framework for configuring and running automated unit tests on client actions. There is also a block, TestResultsBlock, for displaying results of client action unit tests.

Use the K Test Manager forge component to provide a user interface to the manage test scripts and review results.

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

First write a client test script. Then write test cases to verify client actions in multiple scenarios.

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"
  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.
    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 RunTestScript action.
  3. Add an output parameter "Case" of type TestCaseResult.
  4. 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
  5. Assign the returned structure to the output parameter "Case".
  6. 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,
    use Assert_ExpectedException instead, and
    add an Assertion that always fails after the exception should
    have been thrown.
  7. Set up the data to be tested. This is the "Arrange" step.
  8. Call the action to test. This is the "Act" step.
  9. 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.
  10. 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.0.0

The K Test Client Actions Core library provides a framework for configuring and running automated unit tests on client actions.

Use the K Test Manager forge component to provide a user interface to the manage test scripts and review results.

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

First write a client test script. Then write test cases to verify client actions in multiple scenarios.

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

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.
    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 RunTestScript action.
  3. Add an output parameter "Case" of type TestCaseResult.
  4. 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
  5. Assign the returned structure to the output parameter "Case".
  6. 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,
    use Assert_ExpectedException instead, and
    add an Assertion that always fails after the exception should
    have been thrown.
  7. Set up the data to be tested. This is the "Arrange" step.
  8. Call the action to test. This is the "Act" step.
  9. 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.
  10. 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.