Create Code Coverage for webMethods

Introduction

Imagine if you have a requirement of creating a custom regression testing and code coverage tool for webMethods.

Ideally, the best way to go about would be using wmTestsuite which is quite good in taking care of regression test.

Assuming for some reason you didn’t have this and now want to create a tool. I had a scenario where we had to create this from scratch. So thought of sharing the information with the group.

NOTE: I don’t take any credit for the approach as this approach is already used by multiple tools in the market but the amount of effort I spend to develop the tool before I started my journey with Software AG so wanted to share some information with the group.

The approach for this would be

  1. Create a simple service to create testing projects on some configuration files.
  2. Once the project is available create services to create test scenarios that refer to the executable elements of webMethods Integration server.
  3. Create a service which will save test cases i.e. element name, the input /output references.
  4. Next create a service which will run the test case based on the configuration created in step 3 and read the reference input load file and reference output file and run the actual element on the integration server and store the output pipeline.
  5. Create a java or xslt service to do a comparison between the reference pipeline and executed pipeline.
  6. The service created on step 5 can have another list of values that should be excluded for comparison because many times in your flow you have generated fields that will change with each execution.
  7. The results of the service execution and comparisons can be stored in another configuration file i.e. by appending data so that you have reference to all past executions.

Write a service that reads a project, find all services for which test cases are written and then execute each of them. If some test cases end in error or failure still continue with execution and store the error in configuration.

Once you have the unit testing now let’s think of code coverage so you have created a static code coverage tool which is quite simple.

  1. Read your flow.xml and use xslt and xpath using which you can get count of if else and switch , loop, repeat so your total count of test cases would be = Count of If -else + Count of switch + loop + repeat +1.

  2. The above using test cases which are created you can get count of those and do a comparison to get coverage.

NOTE: this approach is static so depends if the user has created the correct test cases. If the developer just copy-paste the same case by changing the name then this approach will not work, I will try to create an article on how once you have unit test cases documented then how you calculate code coverage at run-time.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.