1、Junit的maven依耐
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<!-- <type>...</type> -->
<scope>test</scope>
<!-- <optional>...</optional> -->
<!-- <exclusions>
<exclusion>
<groupId>...</groupId>
<artifactId>...</artifactId>
</exclusion>
</exclusions> -->
</dependency>
2、用@Test注解方法时,测试的类名不能用Test,否则会报错,@Test不能被识别,不能导包;
3、测试方法一:可以在方法上加@Test注解
import org.junit.Test;
public class TestClass {
@Test
public void TestMethod(){
System.out.println("aaa");
}
}
4、测试方法二:测试类继承TestCase类(用这种方法类名可以为Test)
import junit.framework.TestCase;
public class Test extends TestCase{
public void testaaa(){
System.out.println("aaaaaaaa");
}
}