2011-10-28 1 views
0

私はPHPで最近のAPIラッパーコードを書いています。しかし、テストを実行するたびに、すべてのテストが2回実行されます。Simpletestはすべてのテストを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 
} 

いずれかauthentication_test.php内SimpleTestのために電話をautorun.phpまたはその他のために含まれています。

アイデア?

答えて

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ファイルが自動的に実行あなたがもう一度テストを実行()メソッド暗黙のうちに、あなたが実行して呼び出すとき()メソッドを呼び出して、あなたのテストを実行します。 simpletestsのドキュメントから

+0

を使用する必要があり、それはあなたが使用しようとするコードは、すでにあると言いますあなたのコマンドがコマンドラインやブラウザを使用する場合に使用するレポーターを自動的に認識するように、単純なライブラリの中に埋め込まれています。私があなたに示唆したコードは、ブラウザとコマンドラインの両方で適切なReporterで実行されます。 –

0

、私はまだSimpleTestの教祖ないんだけど、私はドキュメントを読んでいる静的メソッド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'); 
    } 
} 
?> 
+0

複数のタグを付けることができれば、これをフォローアップ質問の解決策としてタグ付けします。 –

関連する問題