vendredi 16 juin 2017

How to use Mockito to check number of calls to a function without making Mockito make an extra call

We have made our own framework that makes it easy to setup an analysis pipeline. Every time an analysis ends, finish() is called. finish() uploads files that were generated during the analysis. To ensure that the framework was used correctly, we have made a check that finish() is not called twice.

Now, I want to test that finish() is called for a specific step in the pipeline. I do this by calling the following in my test:

verify(consumer).finish();

But apparently, verify() also calls finish() so an exception is thrown and the test fails.

Now, my question is:

  • How do I avoid that finish() is called twice?

Aucun commentaire:

Enregistrer un commentaire