Service virtualization for testing: do they need statefulness?

Hi Everyone, after speaking to Mr. Bradshaw I was pointed this way with the below tweet I sent out a week or two ago. Would love to hear some thoughts on this!

Boss has posed this question:
Service virtualization for testing: do they need statefulness? Pros/Cons? Or should this be a part of the tests themselves?

My feeling is that statefulness should be part of the test itself rather then the test data. Any other arguments?


If your application behavior changes depending on the state,
then statefulness should be in-built in the behavior of the virtualization software.
Otherwise statefulness is not needed.

It should be part of the virtualization software in addition to being part of your test or data.

Ref: Service virtualization - Wikipedia

Makes sense?

1 Like

There is no one answer, because it depends on your services and what risks your tests are trying to mitigate.

I’ve got Integration Tests where one service needs to be stateful but dependencies are stateless mocks.

You might find it useful to draw a system diagram and define your system under test to visualise your systems and subsystems. Then you can make a choice on what might need to be stateful.

Also, having shared state that potentially impacts multiple tests makes running tests in parallel difficult. But, some more complicated tests may need to change a number of states in a single execution.

It’s worth splitting out what system state each test needs before it starts, as it’s prerequisite. If a prerequisite fails it should ideally be reported as “not run” instead of failed.

Also, if your framework is smart enough, you could use a desired state pattern to change the system state before the test runs.

Thank you both for the replies here - sorry for the delayed response, I have forwarded these to my team and am collating some replies so will be back soon.