1.必须是public,无参,非静态,如下
@Test
public void func() {}
2.Eclipse运行一个test方法
在Package Explorer中选择测试类,展开,从中选择要测试方法, 右键run as->JUint test
3.只添加junit.jar不够,还需添加hamcrest-core.jar这个jar包
4.在meven项目中,pom文件引用了Junit,但是meven Dependices下面却是灰色的,而且调用org.junit报错
原因是pom.xml里面在junit下加了scope为test,所以只能在test下使用,去掉应该可以了。但是实际上还是不行,原来是父项目中还有一个scope,去掉,就OK了