$this->;PHPUnit_TestCase($name);
}
//new一个要测试的类为成员变量abc赋值
function setUp() {
$this->;abc = new fo;
}
//unset要测试的类
function tearDown() {
unset($this->;abc);
}
//自定义的testcase
function testFormatn1() {
//调用要测试的类的方法,结果放到$result变量
$result = $this->;abc->;formatn("100.234");
//期望结果
$expected = "100.23";
//判断是否相等,这里使用assertTrue方法来判断布而值是否为true。
$this->;assertTrue($result == $expected);
}
function testFormatn2() {
$result = $this->;abc->;formatn("0.100234");
$expected = "0.10023";
$this->;assertTrue($result == $expected);
}
function testFormatn3() {
$result = $this->;abc->;formatn("0.100235");
$expected = "0.10024";
$this->;assertTrue($result == $expected);
}
function testFormatn4() {
$result = $this->;abc->;formatn("0.000100235");
$expected = "0.00010024";
$this->;assertTrue($result == $expected);
}
function testFormatn5() {
$result = $this->;abc->;formatn("0.000100232");
$expected = "0.00010023";
$this->;assertTrue($result == $expected);
}
function testFormatn6() {
$result = $this->;abc->;formatn("1343");
$expected = "1343";
$this->;assertTrue($result == $expected);
延伸阅读
文章来源于领测软件测试网 https://www.ltesting.net/