天天看点

javaSE 测试单元, Junit, @Test

Test.java:

package cn.xxx.test;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class Test {
	public static void main(String[] args) {  // 测试单元中可以没有main函数。
		System.out.println("aa");
	}
	
	@Test
	public void testJunit(){  // 测试函数; 在测试函数上--右键--run as--JUnit Test
		System.out.println("hello junit!");
	}
	
	@Before
	public void testBefore(){  // 测试函数之前调用该函数
		System.out.println("before!");
	}
	
	@After
	public void testAfter(){   // 测试函数之后调用该函数
		System.out.println("after!");
	}
	
}