dimanche 14 avril 2019

Mocking an API response type

I have function which accepts an Oracle Jolt ServletResult. I'm looking to unit test this function to verify that it correctly uses the data that it's been passed. ServletResult has a protected Constructor and the objects seem to be created internally in Jolt by a Factory.

I've tried Mocking the ServletResult, but that almost requires re-implementing it. The other option I was thinking about was using reflection to create the object. It seems though that Spring ReflectionTestUtils doesn't seem to handle constructors.

What is the best way to deal with this sort of thing? Should such tests just be left to integration testing rather than unit testing?





Aucun commentaire:

Enregistrer un commentaire