dimanche 30 septembre 2018

How to override class behaviour in a JUnit test

I am trying to create JUnit tests for a method in class A, that creates an instance of class B. Since, I want to isolate the method's behaviour, I would like to override B's methods in my test suite for A with simpler ones, that would work for the purposes of testing A.

I have tried doing so using Mockito's Spy, however as I understand it only allows to return a static value upon a method call, however I need to replace complex external logic with simpler one, while taking into account the parameters passed.

What is the best way to approach this?

Aucun commentaire:

Enregistrer un commentaire