查看spy和auto wire以及extend(SpringExtension)的问题
参数应该是mock,但是是:class org.springframework.data.jpa.repository.support.simplejparepository
@ExtendWith(SpringExtention.class)
@SpringBootTest(classes = TestServer.class)
@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE)
@ActiveProfiles("test")
@Transactional
SampleServiceTest {
@Spy
@Autowire
private TestRepo repo;
@Mock
SpecialTest test;
@Mock
SpecialTest1 test1;
@InjectMock
TestServiceTest testService;
@InjectMock
SampleServiceTest sampleServiceTest;
@BeforeEach()
void setup () {
openMocks(this);
when(testService.getId()).thenReturn(test);
when(testService.getId()).thenReturn(test1);
}
@Test
void test () {
}
当我使用springboot:2.4.1时,我看到了上面的问题。
暂无答案!
目前还没有任何答案,快来回答吧!