Home > Blockchain >  Can not run Junit in eclipse
Can not run Junit in eclipse

Time:12-02

I am trying to run spring boot crud example with following code

@SpringBootTest @RunWith(MockitoJUnitRunner.class)

public class CreateUserServiceTest {

@Mock
private UserRepository userRepository;

@InjectMocks
private CreateUserService createUserService;

@Test
public void whenSaveUser_shouldReturnUser() {
    User user = new User();
    user.setName("Test Name");

    when(userRepository.save(ArgumentMatchers.any(User.class))).thenReturn(user);

    User created = createUserService.createNewUser(user);

    assertThat(created.getName()).isSameAs(user.getName());
    verify(userRepository).save(user);
}

}

But after run it gives bellow error.

"NO test found with test runner 'junit5'"

anyone please help me.

enter image description here

  • Related