package com.phicomme.hu;
public class Student
{
private String name;
private String sex;
private int high;
private int age;
private String school;
public Student(String name, String sex ,int high, int age, String school)
{
this.name = name;
this.sex = sex;
this.high = high;
this.age = age;
this.school = school;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public String getSex()
{
return sex;
}
public void setSex(String sex)
{
this.sex = sex;
}
public int getHigh()
{
return high;
}
public void setHigh(int high)
{
this.high = high;
}
public int getAge()
{
return age;
}
public boolean setAge(int age)
{
if (age >25)
{
return false;
}
else
{
this.age = age;
return true;
}
}
public String getSchool()
{
return school;
}
public void setSchool(String school)
{
this.school = school;
}
}
package com.phicomme.test;
import com.phicomme.hu.Student;
import junit.framework.TestCase;
public class StudentTest01 extends TestCase
{
Student testStudent;
//此方法在执行每一个测试方法之前(测试用例)之前调用
@Override
protected void setUp() throws Exception
{
// TODO Auto-generated method stub
super.setUp();
testStudent = new Student("djm", "boy", 178, 24, "华东政法");
System.out.println("setUp()");
}
//此方法在执行每一个测试方法之后调用
@Override
protected void tearDown() throws Exception
{
// TODO Auto-generated method stub
super.tearDown();
System.out.println("tearDown()");
}
//测试用例,测试Person对象的getSex()方法
public void testGetSex()
{
assertEquals("boy", testStudent.getSex());
System.out.println("testGetSex()");
}
//测试Person对象的getAge()方法
public void testGetAge()
{
assertEquals(24, testStudent.getAge());
System.out.println("testGetAge()");
}
}
package com.phicomme.test;
import junit.framework.TestCase;
import com.phicomme.hu.Student;
public class StudentTest extends TestCase
{
private Student testStudent;
@Override
protected void setUp() throws Exception
{
// TODO Auto-generated method stub
super.setUp();
testStudent = new Student("steven_hu", "boy", 170 , 23, "上海理工");
}
@Override
protected void tearDown() throws Exception
{
// TODO Auto-generated method stub
super.tearDown();
}
public void testSetage()
{
assertTrue(testStudent.setAge(21));
}
public void testGetSchool()
{
//预期值和实际值不一样,测试时出现失败(Failure)
assertEquals("南昌大学", testStudent.getSchool());
}
public void testGetName()
{
assertEquals("hdy", testStudent.getName());
}
}
package com.phicomme.test;
import com.phicomme.hu.StudentTest02;
import junit.framework.Test;
import junit.framework.TestSuite;
public class AllTest
{
//static PersonTest p = new PersonTest();
//static PersonTest p1 = new PersonTest();
public static Test suite()
{
TestSuite suite = new TestSuite("Test for com.phicomme.test");
//suite.addTest(p);
//suite.addTest(p1);
suite.addTestSuite(StudentTest.class);
suite.addTestSuite(StudentTest01.class);
return suite;
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有