有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java发现了组织的问题。莫基托。例外情况。滥用。不允许例外

查看spy和auto wire以及Extend(SpringExtension)的问题

Argument should be a mock, but is: 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 () {
    
    }

当我使用spring boot:2.4.1时,我看到了上述问题


共 (0) 个答案