DEV Community

Discussion on: Testing legacy code, part 1: How to start

Collapse
 
hilaberger92 profile image
Hila Berger

Great article!
When testing your legacy code, do you prefer using a powerful mocking framework or performing more integration tests?

Collapse
 
rapasoft profile image
Pavol Rajzak

Hi! Thank you for response. Well in general I always try to create a scenario that uses real world data. E.g. either creating end-to-end test for specific component, or integration test that would connect to development infrastructure.

But there are also times, where mocking is required, but this is mostly connected to testing specific corner cases that are hard to re-create. It is always something that must be approved within the team.

Collapse
 
hilaberger92 profile image
Hila Berger

Thanks for your answer!
I agree - sometimes mocking is necessary, but not all frameworks give you the ability to do what you need...
Do you know any good mocking frameworks?

Thread Thread
 
rapasoft profile image
Pavol Rajzak

Well for Java we mainly use frameworks/libraries that I mentioned in my next post, e.g. Mockito /w PowerMock, WireMock, etc. and yes, there's no silver bullet to everything, so you need to find the ones for your use case.

Also, the more "advanced techniques" you are using, the more you need to be cautious about your test setup, since a lot of frameworks that have their own classloader or use bytecode manipulation will interfere with each other.

Thread Thread
 
hilaberger92 profile image
Hila Berger

Thanks!
Have you heard about Typemock by any chance?
We started evaluating them and I'm looking for feedback...

Thread Thread
 
rapasoft profile image
Pavol Rajzak

Unfortunately I am not familiar with .NET/C/C#, so no :(

Thread Thread
 
hilaberger92 profile image
Hila Berger

Alright, thanks for your answers!

Thread Thread
 
fedebona_80 profile image
Federico Bonarrigo

Hi Hila,
resuming a very cold post... did you finally try Typemock?