Unit Testing Services

I’m looking for information regarding how to effectively test webMethods Services (flow and java). I found a post regarding using JUnit + HTTPUnit, which is one of the things we’re considering, but it was said that that was not efficient. I’m aware that you can step through services in develeoper, save the pipeline to a file, etc., but does anyone have any good strategies for both coarse-grained testing of the services as a whole, as well as more detailed unit-testing?

tmaun,
This is a hard issue; people seem divided about which approach to use for unit testing I.S. services.

 I've just finished a unit test of a mapping service in wM which uses JUnit - I have four XML instance doc.s  which I use as input. As output from my service I gain a list of HTML form input var.s, which I compare to elements within the original XML (using DOM and regular expressions). I found this to be a fairly effective method. 

 We've also used JMeter for automated unit testing, after we began to use it for load testing. I don't believe JMeter is an effective unit testing tool, nor is it meant to be. It's very good for stress testing but I don't think the Response Assertion framework is powerful enough for every scenario of unit testing we might need.  

 Right now, what bothers me about using JUnit is that it's not a part of the webMethods development framework - it requires webMethod's developers to become comfortable as Java developers. I'm not very bothered by the separation of packages otherwise; it wouldn't be very hard to bundle my JUnit code in my I.S. package or even code a service which called my TestRunner.

Hi Nick,

We’ve been working on a testing framework that we’ll soon package up and release. It’s along the lines of JUnit, but runs within webMethods and doesn’t require you to be a Java guru.

I’ll report back soon.

regards,

-Rob
http://www.customware.net

Rob,
I’m looking foward to seeing it.
A colleague at work is also developing something along these lines, for I.S. 4.6… We’re going to make a comparison between JUnit and a testing suite that is obvious to the I.S. framework when we have something for I.S…

Nick

Robert,

Congrats on the release of the WmUnit testing framework. Have you encountered the need to compare entire XML documents that represent the output of a web service (either one being invoked by WM or one representing a WM flow or java service exposed as a web service)?

Is there a way to assert that the output of a web service equals a document representing an expected result?

Best regards,

Mark Carlson
Conneva, Inc.

Hi Mark,

The need of comparing outputs comes up frequently. Having a quick and easy way to test the results of a mapping service by comparing the string XML generated at the end, with the expected output is quite useful - especially when working in teams and you are not fully aware of the impact of your changes.This comes up even more when you start changing your transformers.

The pattern that we generally work with is to create a packagename_TEST package with the test cases so that you can disable them when they are not required.

To compare the output of a webservice, you can use the assertEquals service to compare the 2 strings of the result and expected result.

regards,

-Rob

[url=“http://www.customware.net/wmunit”]http://www.customware.net/wmunit[/url]

Hmmm. I’m not sure a simple string comparison would do the trick. If the XML document includes timestamps, ID numbers or other variable info, the two documents would not be equal, but the output of the service being tested may still be valid.

Any ideas on comparing subsets of two documents or asserting that the structures of two documents are equal. Seems like I ran across an open source tool to do this, but it is not coming to mind.

I do know that I can write enough Flow to make this happen, but was looking for something a little higher level.

BTW, Is anyone from your company making the trip to IW2003 next month?

Thanks,

Mark

You probably want to use XMLUnit (.org) to compare XML nodes.

That’s the one! Thanks for jogging my memory.

Mark

Hi Rob,

Congrats on the release of the tool.
Does the tool work on webMethods 4.6 and also if there is a evaluation copy of the tool

Thanks,

Gamad

Hi,

We’re working on a 4.6 version and hope to have it soon. Contact me directly (not on the forums) for an eval version. I’ll also be at Integration World.

regards,

-Rob

Just a quick update for anyone following this thread: latest version of WmUnit is available for evaluation if anyone would like a copy.

The typical unit test can be written with just a few lines of flow, rather than having to write clunky java classes which make client calls on the IS.

Features include:
-Creation of unit tests using flow and java services rather than external (junit) code.
-one click execution of sets of unit tests via web interface
-IS version 4.6, 6.0.1 (GA, SP1 and SP2) compatible.
-assertXXX, xml and validation utility services
-documentation (including tutorial and best practices) included

see www.customware.net/wmunit for more details.

cheers,
Nathan Lee

Mark: there’s a utility service for checking for a value in an xml document and also for easy substitution of variables into XML or other text input which might help with your needs (basically feed in an xml string, an XQL (or WQL) query and an expected value and it returns a true/false)