2011-10-28 1 views
0

필자는 PHP에서 최신 API 래퍼 코드를 작성하기 위해 노력한 간단한 테스트 스위트를 보유하고 있습니다. 그러나 테스트를 실행할 때마다 모든 테스트가 두 번 실행됩니다.Simpletest에서 모든 테스트를 두 번 실행하고 있습니다. 왜?

내 호출 코드 :

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

하나 이상의 태그를 붙일 수 있다면이 질문에 대한 후속 질문의 해결책으로 태그를 달았습니다. –