"unsatisfied dependency during test" Code Answer

3

you need to annotate the test with springboottest so that spring initialize an application context

https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-testing.html#boot-features-testing-spring-boot-applications

@springboottest
@runwith(springjunit4classrunner.class)
public class addressservicetest {
// the remaining test
}

also you do not need mockitoannotations.initmocks(this);

spring takes care of the mock handling

when [@mockbean is]used on a field, the instance of the created mock will also be injected. mock beans are automatically reset after each test method

see mocking and spying beans

By 1077 on July 1 2022
Only authorized users can answer the Search term. Please sign in first, or register a free account.