Sathesh
Sathesh

Reputation: 496

Is there a way for @MockBean to be used for a single test?

I am writing a new SpringBoot unit test which requires injecting a @MockBean which I added and is working as expected. But unfortunately, the mockbean is messing up with some of the existing tests causing them to fail. Is there any way I can inject @MockBean to the particular test alone so that the other tests are unaffected? Thanks

Upvotes: 0

Views: 1713

Answers (1)

knittl
knittl

Reputation: 265291

One option is to create a second test class which only contains a single test. The MockBean will then not affect the existing tests.

Upvotes: 1

Related Questions