首页 > 数据库技术 > 详细

jdbc:关于junit测试No tests found matching

时间:2017-07-05 09:31:49      阅读:565      评论:0      收藏:0      [点我收藏+]

当被测试的方法中含有以【@Test】标记的被调用的方法方法时,就会报No tests found matching。。。

from org.junit.internal.requests.ClassRequest@306a30c7的错误,将被调用的方法的【@Test】去掉即可。

@Test
 public void testSatement(){
  Connection connection=null;
  Statement statement=null;
  ResultSet resultSet=null;
  try {
   //1.获取数据库连接
   connection=getConnection();
   //2.调用Connection对象的createStatement()方法获取Statement对象
   statement=connection.createStatement();
   //3.准备SQL语句
   String sql="update customers set name=‘Jerry‘ where id=6";
   
   //4.发送SQL语句:调用Statement对象的executeUpdate(sql)方法
   statement.executeUpdate(sql);
  } catch (Exception e) {
   e.printStackTrace();
  }finally{
   //5.关闭数据库资源:由里向外关闭
   releaseDB(resultSet, statement, connection);
  }

比如上述测试中需保证方法getConnection()和releaseDB(resultSet, statement, connection)不应有【@Test】,负责就会报上述错误

注:junit4----junit_4.12.0.v201504281640


  

jdbc:关于junit测试No tests found matching

原文:http://www.cnblogs.com/cd-01/p/7119264.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!