Test Suite Executor

One of the most critical phase of any development project is testing , to ensure that the implemented features work as expected. Automation of testing process enables repeated executions of the test cases leading to more accuracy and time saving. In webmethods product suite, the automated unit testing capability is provided as Unit testing framework (earlier known as wMTestSuite). This article explains about using the Unit testing framework in a headless mode.

Note : This article does not cover the basics of creating / executing the test suite, it is rather focused on using the headless testing using the Test Suite Executor feature. It is expected that the reader has knowledge of creating and executing test cases using Unit testing framework tool.

Headless Execution of test cases

In general, Headless testing is a mode of running the tests without the head, which means there is no specific UI, or any GUI used. This becomes extremely useful when running any automated tests in a CI / CD implementation, where the primary focus may not be on visualizing the test executions on a GUI. The tests can be simply run in the background.

With this approach, the test execution becomes very light weight utilizing less system resource as we can get rid of the overhead involving the UI to render the test results or any other processes involved to display the test results.

In webMethods, the headless tests can be invoked using the Test Suite Executor features accessible through the designer. It provides default Ant script and easily modifiable property files to implement headless test invocation setup.

Creating test suite executor

Perform the following steps to create a sample test suite executor using the default files.

  1. Select File>New> Test Suite Executor in Unit Test Framework Perspective of SoftwareAG Designer.
  2. On the Test Suite Executor Project screen , enter the project name, folder path that contains the test suite setup files, and the file system. You can choose to use the default values.
  3. Click Finish .

Note : Before creating the test suite executor project, the test suites project should already be available.

Project contains default Ant build targets and properties to drive the tests. Below is a sample test executor project and its project structure,

image

Configuring test suite executor

Using Designer, you can configure the Test Suite executor after you have successfully created the projects. Perform the following steps to configure a sample test suite using the default files.

  1. To initiate the tests, use the ant build file, run-composite-runner.xml and ant target, composite-runner-all-tests
  2. Modify the properties file, run-test-suites.properties to specify project locations and setting up target Integration Server definition
  3. Specify appropriate values for each property in the run-test-suites.properties file to generate the results in the provided location as HTML files.

Note : Use readme.md for the details of each field defined in property file. To run the headless testing set webMethods.test.setup.profile.mode =NONE

Executing the project

  1. You can create a run configuration , Navigate > ‘External Tools configuration

image

  1. Create a new Ant configuration ,

image

  1. Give a configuration name and select ‘run-composite-runner.xml’ file from the workspace.
  2. Click on run .

Viewing the results
From the designer , In the project folder , right click on the ‘ index.html ’ and open with any often provided options.

image

image

Note: You can also use Nodejs, tomcat etc. to view the report locally. In Realtime scenario, this execution would be done by Jenkins and Jenkins HTML publisher plugin to view the report from Jenkins Server.

Coverage

Another important aspect of any testing activity is the test coverage which plays a crucial role to ensure that every part of the code is tested as part of the test cases designed. Unit Test Framework allows you to record and analyze which flow steps and map actions of your flow service(s) are executed during a test launch. It helps to identify untested steps and improve the corresponding tests.

Pre-requisites:

Before running the test coverage analysis, ensure that you activate the wM Code Coverage Agent. To activate the wM Code Coverage Agent, perform one of the following steps:

  1. On the Package Navigator right-click the default Integration Server instance and select wM Code Coverage Agent > Activate

OR

  1. In Designer, navigate to Window > Preferences > Software AG > Integration Server and
  • select the default server.
  • Click wM Code Coverage Agent.
  • On the wM Code Coverage Agent Settings dialog, select Activate .

To run a test coverage analysis

Set the property webMethods.test.setup.profile.mode =COVERAGE in the property file and follow the same execution steps as mentioned in earlier section

Viewing Code Coverage Analysis

After you run the test, wM Code Coverage view displays a detailed coverage report of

the test session. The tested flow steps and map actions or Services appear in green and the untested flow steps and map actions appear in red.

You can view the code coverage report locally through NodeJs or Tomcat by just coping the ‘wmcodecoverage’ folder that contains all the report resources to the specific location of these servers.

You can use the Jenkins HTML publisher plugin to publish the code coverage reports if execution is done by Jenkins.

image

Full Packages View - Represent elements under the corresponding Packages and Service namespace. This View provides detailed coverage analysis of the flow steps and map actions of all the individual service(s) under test in the test suite.

Execution Model View - Represent elements based on invocation hierarchy. This View provides individual test coverage analysis of the flow steps and map actions of the individual service(s) involved in the test case.

Service Level View - Represent only Invoked Services as elements under corresponding Packages. This view provides the coverage analysis of only the services invoked during the test case or test suite execution. This would be primarily be interested to developers.

For a quick start , you can use the inbuilt sample provided to create the test suite executor as mentioned in below steps,

  1. Select File > New > Test Suite Example

image

  1. Click on Next , On the Test Suite Executor Project screen, enter the project name, chose the default location to the Integration server package location

image

  1. Click Finish . Below project is created in the workspace with the necessary build path automatically configured.

This project already contains few sample services and its corresponding test cases in the same project. In the actual project use-cases, the core services and the test suite projects will be maintained separately.

image

  1. Create the Test suite executor project and configure below properties,

image

  1. Right click on the ant build file ‘run-composite—runner.xml’ > Run As > External tool configuration and create an Ant configuration.

image

  1. Click Run , After the execution completes the reports will be generated in the respective folders based on the chosen profile mode,

project/test/reports/html > If executed with no coverage mode (webMethods.test.setup.profile.mode =NONE)

project/test/reports/wmcodecoverage > If executed in coverage mode (webMethods.test.setup.profile.mode =COVERAGE)

image

1 Like