问题
file1:
<?php
require_once('simpletest/autorun.php');
require_once('simpletest/web_tester.php');
class TestOfRankings extends WebTestCase {
function tesetWeAreTopOfGoogle() {
$this->get('http://poll:8888/index.php/admin/unit_test');
$this->assertText('this is good');
}
}
?>
file2:
require_once('simpletest/autorun.php');
require_once('simpletest/web_tester.php');
class MakTest extends WebTestCase {
function testOneAndOneMakesTwo() {
$this->get('http://poll:8888/index.php/admin/unit_test');
$this->assertText('this is good');
}
}
almost identical files, why do they give me different result?
file1.php
OK
Test cases run: 0/2, Passes: 0, Failures: 0, Exceptions: 0
file2.php
OK
Test cases run: 1/2, Passes: 1, Failures: 0, Exceptions: 0
回答1:
According to the SimpleTest docs:
When a test case runs, it will search for any method that starts with the string "test" and execute that method. If the method starts "test", it's a test.
In file1
the function name is tesetWeAreTopOfGoogle
(this seems to be a typo). Switch to testWeAreTopOfGoogle
and you'll be golden.
回答2:
Your functions probably need to start with test. tesetWeAreTopOfGoogle should be testWeAreTopOfGoogle?
来源:https://stackoverflow.com/questions/13060495/strange-thing-using-simple-test-in-php