I have a specific chain of test methods in a test class using Spec2:
def is = "EntriesServlet with logged user" ^ "POST / request should update entry that user owns" ! updateExistingEntryThatLoggedUserOwns ^ "POST / request should not update non existing entry" ! notUpdateNonExistingEntry ^ "POST / request should not update non owner entry" ! notAllowToUpdateNotOwnedEntry end
and in these methods I check if mock has been defined. But I need to recreate one layout, so I could only count calls for one method non-globally.
So, I need a way to easily define let say method:
def prepareMocks = { serviceMock = mock[MyService] }
which will be executed before each test method so that I have a clean layout before checking my claims.
I tried with the BeforeEach and BeforeExample from Spec2, but they are not what I am looking for.
source share