遇到个问题请教下 @RunWith(SpringJUnit4ClassRunner.class) @org.springframework.test.context.ContextConfiguration(locations={"file:WebRoot/WEB-INF/applicationContext.xml"}) public class CheckUtil { @Autowired private CheckkeyidMapper checkkeyidMapper; @Test public void GetKeyidinfo(){ String Status = "N"; Map map = new HashMap(); map.put("name","gg"); map.put("keyid","2"); try { int count = checkkeyidMapper.checkkeyid(map); if(count == 0){ Status = "E"; } }catch (Exception e) { Status = "E"; } } } 这样用JUnit运行测试是正常的 可是我换成public String GetKeyidinfo(String name, String keyid) 传入参数在程序里面调用, public class CheckUtil { @Autowired private CheckkeyidMapper checkkeyidMapper; @Test public String GetKeyidinfo(String name, String keyid){ String Status = "N"; Map map = new HashMap(); map.put("name","gg"); map.put("keyid","2"); try { System.out.println("map+++++"+map); int count = checkkeyidMapper.checkkeyid(map); System.out.println("count ==========================="+count); if(count == 0){ Status = "E"; } }catch (Exception e) { Status = "E"; } return Status; } } |
|
你打印一下异常信息看看
|
|
20分 |
Method GetKeyidinfo should be void ;
Method GetKeyidinfo should have no parameters |
80分 |
JUNIT 测试方法必须为void 并且不能有参数 ,我也是刚学习的
|