Hi all! I am using mockk for tests but keeps failing to mock the calls that I expect, when I try running all tests from cli (with gradle:
gradle :test
). when run individually with
kotest
runs perfectly. I have something like this:
beforeSpec {
Application.start()
mockkObject(MyObjectClass)
every { MyObjectClass.getRandomString() } returns "call made"
})
afterSpec {
clearAllMocks()
Application.stop()
}
....
// some other tests that should make calls to the function that I mocked above
"verify mockk" {
verify(exactly = 7) {
MyObjectClass.getRandomString()
}
}
I can't figure out what could be wrong here, I get this error when run from the command line :
java.lang.AssertionError: Verification failed: call 1 of 1: MyObjectClass(object MyObjectClass).getRandomString()) was not called .......
Any help is appreciated, thank you! 🙏