exampletest.java
import junit.framework.*;
/**
* some tests.
*
*/
public class exampletest extends testcase {
public triangle triangle;
//初始化
protected void setup() {
triangle=new triangle(10,2,9);
}
public static test suite() {
return new testsuite(exampletest.class);
}
//函數(shù)istriangle()的測試用例
public void testistriangle() {
asserttrue(triangle.istriangle(triangle));
}
//函數(shù)istype()的測試用例
public void testistype()
{
assertequals("這次測試",triangle.istype(triangle),"不等邊三角形");
}
//執(zhí)行測試
public static void main (string[] args) {
//文本方式
junit.textui.testrunner.run(suite());
//swingui方式
//junit.swingui.testrunner.run(suite().getclass());
//awtui方式
//junit.awtui.testrunner.run(suite().getclass());
}
}