2009-11-03 3 views
4

내 상사가 Kohana를 사용하는 방법을 배우고 간단한 테스트를 구현하도록 배웠습니다. 우리는 향후 프로젝트를위한 프레임 워크로 사용하고자합니다.Kohana에서 SimpleTest를 구현하는 방법

KohanaPHPSimpleTest에 새로 추가되어서, 내 도우미의 가장 단순한 테스트조차 할 수 없다. SimpleTest를 Kohana에 연결하는 방법에 대한 단계별 자습서도 하나도 없습니다.

누구나 여기에 아이디어가 있습니까?

답변

4

우리는

Kohana

에 SimpleTest_controller을 만든 및 모든 을 실행하는 domain.com/simpletest를 호출 할 수 있습니다 또는 당신이 accountfolder이있는 경우 domain.com/simpletest/run/account를 호출 할 수 있습니다 그것은 디렉토리 테스트

define ('SIMPLE_TEST', '../tools/simpletest/'); 
require_once(SIMPLE_TEST . 'unit_tester.php'); 
require_once(SIMPLE_TEST . 'reporter.php'); 
require_once(SIMPLE_TEST . 'mock_objects.php'); 

class SimpleTest_Controller extends Controller { 
    function index() { 
    $this->runall(); 
    } 

    function runall() { 
    $sDir = '../tests/'; 
    $rDir = opendir($sDir); 

    while ($sFile = readdir($rDir)) { 
     if ($sFile != '.' && $sFile != '..') { 
     $this->run($sFile); 
     } 
    } 
    } 

    function run ($sTests) { 
    $sDir = '../tests/' . $sTests .'/'; 
    $rDir = opendir($sDir); 
    $test = new GroupTest($sTests); 

    while ($sFile = readdir($rDir)) { 
     if ($sFile != '.' && $sFile != '..' && !preg_match('/~\d+~/', $sFile)) { 
     include_once($sDir . $sFile); 
     $test->addTestCase(substr($sFile, 0, -4)); 
     } 
    } 

    $test->run(new HtmlReporter()); 
    } 
} 

에서 테스트를 가져옵니다 당신의 testfolder에

+0

감사합니다, 그것은 매력과 같은 작품입니다! – ariefbayu

관련 문제