初学mybatis spring 和struts2
遇到个问题请教下
这样用JUnit运行测试是正常的
@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";
}
}
}
可是我换成public String GetKeyidinfo(String name, String keyid) 传入参数在程序里面调用,
int count = checkkeyidMapper.checkkeyid(map); 不执行也没有结果,不知道是什么原因
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;
}
}
------解决思路----------------------
Method GetKeyidinfo should be void ;
Method GetKeyidinfo should have no parameters
------解决思路----------------------
JUNIT 测试方法必须为void 并且不能有参数 ,我也是刚学习的
