2010-08-12 16 views
5

Ben yani., TestAc1, testAc4, testAc7 vb tüm yöntemler çalıştırılır Bu komut dosyasını çalıştırdığınızda Bu benim Birim Test sınıfıEn basit en kısa sınıfta tek bir test yöntemi nasıl çalıştırılır?

<? 
require_once '../simpletest/unit_tester.php'; 
require_once '../simpletest/reporter.php'; 
class Academic extends UnitTestCase 
{ 
    function setUp() 
    { 
    } 
    function tearDown() 
    {       
    } 
    function testAc1() 
    {   
    } 
    function testAc4() 
    {   
    }  
    function testAc7() 
    {   
    } 

} 

$test = new Academic(); 
$test->run(new HtmlReporter()); 
?> 

olduğunu. Sadece tek bir yöntemi yürütmenin bir yolu var mı?

sayesinde Shikhar

cevap

3

SimpleTest kaynağı biraz karıştırmaya sonra, ben sadece dahil Burada en kolay yolu aşağıdaki gibi testin getTests() yöntemini geçersiz etmektir

require_once('simpletest/autorun.php'); 

class Academic extends UnitTestCase 
{ 
    # .. 
    function testAc7() 
    {   
    } 

    function getTests() 
    { 
    return array("testAc7"); 
    } 
} 

bulduk her zamanki gibi autorun.php, sadece getTests() adlı testler çalıştırılacaktır.

+0

Harika fikir @Tristan Havelick teşekkürler –

İlgili konular