问题
I have some mocks created using:
val someService = mockk<SomeService>(relaxed = true)
There are multiple tests in the file and I want the mock to be reset for each test
Is there currently a way to do this in MockK?
I know there is MockKAnnotations.init(this), but it didn't look like there was a way to set relaxed = true in the @Mock annotation
回答1:
For resetting mocks in MockK you can use clearMocks
. To create relaxed mock via annotation just check @RelaxedMockK
来源:https://stackoverflow.com/questions/48894560/mockk-reinitialize-mocks-for-each-test