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.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…