Integration test
- Create Spring Boot Test (Integration test with the application context loading)
- Provide mock instance of
HelloWorldServiceHelloWorldService#helloWorld()return"Hello World"HelloWorldService#echo(String)returns"KPJ echo"for all inputs
- Add asserts and JUnit annotations
- Verify the
HelloWorldService#helloWorld()was called - Assert the
KpjTesting#printEcho(String)returns"KPJ echo"
- Verify the
Unit test
- Create Spy on the
KpjTesting#helloWorldServicefield - Add JUnit annotations
- Verify the
HelloWorldServiceImpl#helloWorld()is called - Change behavior of
HelloWorldServiceImpl#echo(String)to always returns"KPJ Rulez"