Junit4报错-No tests found matching Tests

Junit4-No tests found matching Tests from org.junit.runner.Request
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {SpringConfig.class})
public class SpringTest {
//    ClassPathXmlApplicationContext classPathXmlApplicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
//    AccountService accountService = (AccountService) classPathXmlApplicationContext.getBean("accountService");
//    AnnotationConfigApplicationContext annotationConfigApplicationContext = new AnnotationConfigApplicationContext(SpringConfig.class);
//    AccountService accountService = (AccountService) annotationConfigApplicationContext.getBean("accountService");
 @Autowired
 private AccountService accountService;
 @Test
 public void testSave(){
        Account account = new Account();
 account.setName("乌冬面");
 account.setMoney(7777);
 accountService.save(account);
 }
    @Test
 public void testUpdate(){
        Account account = new Account();
 account.setName("希宝");
 account.setId(7);
 accountService.update(account);
 }
    @Test
 public void testDelete(){
        Account account = new Account();
 account.setId(8);
 accountService.delete(account);
 }
    @Test
 public void testFindAll(){
        List all = accountService.findAll();
 for (Account account : all) {
            System.out.println(account);
 }
    }
    @Test
 public void testFindById(){
        Account account = accountService.findById(6);
 System.out.println(account);
 }
    public void test(){
    }
}

在上述代码编写完成后, 点击运行其中一个测试方法,就会报标题中的错误

解决方式是:
先运行整个测试类, 成功后, 再运行其中一个测试方法

另,
导包应该导的是import org.junit.Test,不能导import org.junit.jupiter.api.Test

你可能感兴趣的:(java,junit)