BT

Service Virtualization as an Alternative to Mocking

by Jonathan Allen on Apr 22, 2013 |

Mocking via dependency injection is often a messy endeavor. For even the simplest of applications it often involves creating new interfaces, taking on a dependency on an IoC Container, and in general adds a lot of unnecessary complexity. And after all that, you still have to write the mocks themselves, many of which aren’t useful for anything besides simplistic unit tests.

Products such as CA Lisa Service Virtualization offer an alternative approach. Rather than mocking individual classes, these testing tools allow you to mock entire services at the network level. From the application’s perspective it is talking to a real service backend, even though in reality that backend may not even exist yet.

There are two common ways of setting up a virtualized service. The first is to start with the contract (e.g. a WSDL or other protocol-specific descriptor) and create pre-determined responses. This can be done manually using normal Java or .NET code, or you can use a commercial product. An advantage of this method is that the team writing the component doesn’t have to wait for the real version of the service to be completed. The downside is that the real version needs to actually match the fake one, which becomes a questionable proposition as timelines become longer.

The other route is to use traffic recordings. A tool sits between the component under test and its down-stream dependencies. This tool basically acts as a proxy, gathering information about how the components interact. Later those recordings can be used to simulate the conversation between the component and the servers it depends on.

Both routes are viable for most communication protocols. With the right plugins and filters, the test tool should be able to understand message queues, REST, SOAP, raw TCP, or any other means of exchange.

Rate this Article

Relevance
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

each has there place by Peter Taylor

I think mocking makes sense at a unit test level. Good IOC containers have a great deal of value and rarely do harm. Loosely coupled code is the key to success. When you are ready to think about integration testing then service virtualization makes sense.

IBM also have a commercial offering in this space called Rational Integration Tester.
Peter Taylor
An IBM employee not speaking on behave of IBM

Re: each has there place by Jonathan Allen

If you would be interested in writing a short article about Rational Integration Tester please contact me at jonathan@infoq.com. I'm sure many of our readers would find that product to be useful.

mocktail - Open source service-virtualization solution by ShriKant Vashishtha

We have been working in this space for quite a while to create an open-source solution for Java platform. The solution not only virtualises the web-services response the way Lisa does but at also potentially generic solution for any external interface. You can virtualise the database also which is handy when you want to record a test case with production scenario and prod-db may not be available.

Currently it's in beta but will be available soon.

mocktail.svashishtha.com/
github.com/vashishthask/mocktail/

Re: mocktail - Open source service-virtualization solution by Jonathan Allen

Send a note to Charles Humble, our lead editor for Java news, once it's ready. I'm sure he would be interested in it.

www.infoq.com/about

There is many more tools by Wojciech Bulaty

en.wikipedia.org/wiki/Service_virtualization#To...

Other popular tools for testers/QAs: SoapUI (HTTP), Ready! API (HTTP), Parasoft Virtualize (HTTP/TCP/MQ/...).
Popular tools for developers: WireMock (HTTP), betamax (HTTP), mountebank (HTTP/TCP), VCR (HTTP).

Virtualization using CA-Lisa by Jino Matthew

I have been using CA-Lisa in our company , and have to say its by far the industry leader in virtualization . Easy to use and very robust tool , supporting all protocols in the industry .

If you are looking to get trained in LISA do visit

www.qatrainingworld.com/product/itkoca-lisa-virtualize-online-training/

and see what they have to offer .

You can also register here for a free demo class

www.qatrainingworld.com/register/

many such tools - including Wilma by Tamas Kohegyi

There are tools: en.wikipedia.org/wiki/Service_virtualization</ä>

And there are tools those can combine both routes (mock entire service AND act as proxy and record traffic), like the open sourced Wilma (epam.github.io/Wilma/).

Great read thanks. by Julia Frohwein

You might find it helpful to look at real user reviews of all the top Service Virtualization tools on IT Central Station. You mentioned in your article CA Service Virtualization which is currently rated #1 on our site: goo.gl/v58hed.

This QA Manager looked at a few different options before making his decision: "We considered HP SV, IBM GreenHat, Parasoft, and others. The benefits with CA SV are cost savings on hardware and earlier defect identification". To see the rest of his review click here: goo.gl/y9az8a.

Hope this is helpful.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

8 Discuss
General Feedback
Bugs
Advertising
Editorial
Marketing
InfoQ.com and all content copyright © 2006-2016 C4Media Inc. InfoQ.com hosted at Contegix, the best ISP we've ever worked with.
Privacy policy
BT

We notice you’re using an ad blocker

We understand why you use ad blockers. However to keep InfoQ free we need your support. InfoQ will not provide your data to third parties without individual opt-in consent. We only work with advertisers relevant to our readers. Please consider whitelisting us.