Jump to:

17452 Posts in 4473 Topics by 1971 members


SilverStripe Forums » Archive » [Solved] Problems with extending the TestRunner (sapphire/testing/TestRunner.php)

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

Page: 1
Go to End
Author Topic: 1332 Views
  • dp-Hannes
    Community Member
    1 Post

    [Solved] Problems with extending the TestRunner (sapphire/testing/TestRunner.php) Link to this post

    Problem solved! To create the files, php just needed a (MUCH!) higher Memory Limit! ... but here for the Record:

    Hi People,

    i've come to a mysterious Problem while i try to extend the 'sapphire/testing/TestRunner.php' to do some CodeCoverage etc.

    In Theory its quite simple, i've my /root/config.xml that does some ...well.. you may guessed it, configurations:

    <log type="coverage-html" target="/tmp/tests/report" charset="UTF-8"
    yui="true" highlight="false"
    lowUpperBound="35" highLowerBound="70"/>
    <!--<log type="coverage-xml" target="/tmp/tests/coverage.xml"/>-->
    <log type="metrics-xml" target="/tmp/tests/metrics.xml"/>
    <log type="plain" target="/tmp/tests/logfile.txt"/>
    <log type="pmd-xml" target="/tmp/tests/pmd.xml" cpdMinLines="5" cpdMinMatches="70"/>
    <log type="test-xml" target="/tmp/tests/logfile.xml" logIncompleteSkipped="false"/>
    <log type="testdox-html" target="/tmp/tests/testdox.html"/>
    <log type="testdox-text" target="/tmp/tests/testdox.txt"/>

    regulary you can add this config file to a run of a PHPUnit test that way:

    PHPUnit_TextUI_TestRunner::run($suite,array('configuration' => '/root/config.xml'));

    i set that up in a small PHPUnit Test-Suite:



    require_once 'PHPUnit/Framework.php';
    require_once 'PHPUnit/TextUI/TestRunner.php';


    $suite = new PHPUnit_Framework_TestSuite();

    /*, array("reportDirectory" => "/Users/sminnee/phpunit-report")*/
    PHPUnit_TextUI_TestRunner::run($suite,array('configuration' => '/root/config.xml'));


    if i call it from the command line, works out just fine, Tests running trough, code coverage done, developer == happy.

    Now there is a similar Thing in the sapphire/testing/TestRunner.php in Line 70, i just added the configuration, in exactly the same way, and since the TestRunner ist just a wrapper for PHPUnit i guess there is no Reason why i shouldnt work out. But if i try to start the Test with '~ php cli-script.php /TestRunner' it starts, run through all Tests, writes out that it starts doin' the first line of my configuration (in that case the metrics-xml) but then allways interrupts, without any message, error, warning or any coverage done..

    i really dont get why

    appendix :

    After some work it kinda looks like its somehow connected to the test Class itself, or to be more precise , its lenght, for example, that works:

    class FormularTest extends SapphireTest {
    function testHasAttribute() {
    $this->assertClassHasStaticAttribute('db','FileSubmission','Attribut db nicht vorhanden!');

    that does not (interrupts while stile should write stuff in my files):

    class FormularTest extends SapphireTest {
    function testHasMethod() {
    $fp = new FormularPage();
    $fc = new FormularPage_Controller($fp);

    $this->assertTrue($fc->hasMethod('doFile'), "doFile Methode ist nicht vorhanden!");
    $this->assertTrue($fc->hasMethod('FileForm'), "FileForm Methode ist nicht vorhanden!");

    function testHasAttribute() {
    $this->assertClassHasStaticAttribute('db','FileSubmission','Attribut db nicht vorhanden!');
    function testBasicView() {
    $response2 = Director::test('formular/', null, null);
    $this->assertTrue(strpos($response2->getBody(), '<h1>teeeeeeeeeeeeest') !== false);
    $this->assertTrue(strpos($response2->getBody(), '<form id="Form_FileForm"') !== false);


Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.