0

私は、PHPで最近のAPIラッパーコードのいくつかのために書いている最も単純なスイートを持っています。しかし、テストを実行するたびに、すべてのテストが2回実行されます。

私の発信コード:

require_once(dirname(__FILE__) . '/simpletest/autorun.php');  
require_once('CompanyNameAPI.php');


$test = new TestSuite('API test');
$test->addFile(dirname(__FILE__) . '/tests/authentication_test.php');
if (TextReporter::inCli()) {
    exit ($test->run(new TextReporter()) ? 0 : 1);
} else {
    $test->run(new HtmlReporter());
}

authentication_test.phpは次のようになります:

class Test_CallLoop_Authentication extends UnitTestCase {  

    function test_ClassCreate(){
        $class = new CallLoopAPI();
        $this->assertIsA($class, CallLoopAPI);
    }
        //More tests
}

autorun.phpへのインクルードやauthentication_test.php内のsimpletestへの他の呼び出しもこれ以上ありません。

アイデア?

4

2 に答える 2

2

次のように通話コードを変更する必要があります。

require_once(dirname(__FILE__) . '/simpletest/autorun.php');  
require_once('CompanyNameAPI.php');

$test = new TestSuite('API test');
$test->addFile(dirname(__FILE__) . '/tests/authentication_test.php');

autorun.phpファイルは、run()メソッドを呼び出してテストを自動的に実行します。run()メソッドを呼び出すと、テストが再度実行されます。

于 2011-12-06T18:20:44.783 に答える
0

simpletestsのドキュメントから、静的メソッドを使用する必要がありますprefer(REPORTER)

<?php
require_once('show_passes.php');
require_once('simpletest/simpletest.php');
SimpleTest::prefer(new ShowPasses());
require_once('simpletest/autorun.php');

class AllTests extends TestSuite {
    function __construct() {
        parent::__construct('All tests');
        $this->addFile(dirname(__FILE__).'/log_test.php');
        $this->addFile(dirname(__FILE__).'/clock_test.php');
    }
}
?>
于 2013-05-17T05:27:11.097 に答える