在写测试类时报错,java.lang.Exception: No tests found matching Method

java.lang.Exception: No tests found matching Method testDelete(com.itheima.test.HibernateDemo03) from org.junit.internal.requests.ClassRequest@6576fe71
 at org.junit.internal.requests.FilterRequest.getRunner(FilterRequest.java:37)
 at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.(JUnit4TestReference.java:33)
 at org.eclipse.jdt.internal.junit4.runner.JUnit4TestMethodReference.(JUnit4TestMethodReference.java:25)
 at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:54)
 at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:38)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:444)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

  public void testDelete(){
    Session session=HibernateUtil.openSession();
     Transaction tx=session.beginTransaction();
     Customer  c=   session.get(Customer.class, 13L);
        session.delete(c);
      tx.commit();
      session.close();

解决方案原因: 在public 方法前加上@Test,调用测试方法。

你可能感兴趣的:(错误原因及解决方案)