3

This is my code snippet:

@Test
fun `request should return anon id if query param present`(@MockK(relaxed = true) req: ServerRequest)

I'm using JUnit5(Jupiter). The exception I've got is:

io.mockk.MockKException: no answer found for: ServerRequest(#1).cookies()

This is weird because if I understood relaxed correctly, my instance of ServerRequest should always have some value.

Why doesn't it in my case?

yuranos
  • 8,799
  • 9
  • 56
  • 65

1 Answers1

5

I figured out while I was writing the question that there is another alternative to specify relaxed, via @RelaxedMockK. And imagine my surprise, it works:

@Test
fun `request should return anon id if query param present`(@RelaxedMockK req: ServerRequest) {
yuranos
  • 8,799
  • 9
  • 56
  • 65