Reputation: 11
Im trying to use the save from my repository EmpresaRepository, but it returns null, heres my repository heres my repository and this is my test
Upvotes: 1
Views: 2157
Reputation: 1641
This is the expected behaviour.
By using @MockBean
you create and add a Mock of your EmpresaRepository into the ApplicationContext
.
This means you execute the ::save()
Method of your mock which returns null
bey default.
Rule of thumb: Never Mock the thing you want to test.
The test should work if you replace the @MockBean
annotation with Autowired
.
Btw. please don't post screenshots of your code. It's annoying to switch between different tabs and also I'm not able to copy parts of your code.
Upvotes: 1