Код: Выделить всё
@Configuration
@RequiredArgsConstructor // ... using Lombok
public class MyConfigClass {
private final MyService myService;
@PostContruct
void setup(){
String s = myService.aMethod();
System.out.println(s.substring(0, 2));
}
}
Код: Выделить всё
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE)
class SomeOtherServiceTest {
@MockBean
private MyService mockMyService;
@BeforeEach
void setup() {
when(mockMyService.aMethod()).thenReturn("blablabla"); // ... using Mockito
}
@Test
void test() {
// test code
}
}
Как мне этого добиться?
Подробнее здесь: https://stackoverflow.com/questions/791 ... tion-class