Strange thing using simple test in Php

ε祈祈猫儿з 提交于 2019-12-24 20:27:38

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!