Skip to content

Commit

Permalink
Merge pull request #1108 from bboeck/issue-963
Browse files Browse the repository at this point in the history
Issue 963: Unnecessary stubbings detected - false positive
  • Loading branch information
Raibaz committed Jul 3, 2023
2 parents 80e43ea + 1eeff45 commit f559626
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions modules/mockk/src/jvmMain/kotlin/io/mockk/junit5/MockKExtension.kt
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,18 @@ class MockKExtension : TestInstancePostProcessor, ParameterResolver, AfterAllCal
unmockkAll()
}

if (context.confirmVerification) {
confirmVerified()
}
try {
if (context.confirmVerification) {
confirmVerified()
}

if (context.checkUnnecessaryStub) {
checkUnnecessaryStub()
if (context.checkUnnecessaryStub) {
checkUnnecessaryStub()
}
} finally {
// Clear all mocks after missed verifications or unnecessary stubs. Solves Issue #963.
clearAllMocks()
}

clearAllMocks()
}

private val ExtensionContext.keepMocks: Boolean
Expand Down

0 comments on commit f559626

Please sign in to comment.