軟體工程筆記

Java工具-Junit4編寫單元測試-jUnit4初測試使用

JUnit是一個Java語言的單元測試框架。

JUnit是一個Java語言的單元測試框架。

`package junit4test;

import static org.junit.Assert.*;

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

public class test5 {
	String result;
	int score;
	
	@Before
	public void test1() throws Exception {
		score=66;
	}
	@Test
	public void test2() {
		
		if(score>=60) {
			result="合格";
		}
		else if(score<60){
			result="不合格";
		}
	}
	@After
	public void test3() {
		System.out.println(result);
	}

}
`