Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Archive /

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

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

[Solved] Problems with extending the TestRunner (sapphire/testing/TestRunner.php)


Reply


1369 Views

Avatar
dp-Hannes

Community Member, 1 Post

22 July 2008 at 10:28pm

Edited: 23/07/2008 4:01am

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:

/root/config.xml
<phpunit>
<logging>
<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"/>
</logging>
</phpunit>

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:

suite.php

<?php

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

require_once("BankAccount3Test.php");
require_once("../tempfiles/BankAccount3.php");

$suite = new PHPUnit_Framework_TestSuite();
$suite->addTestSuite("BankAccount3Test");

/*, 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:

<?php
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):

<?php
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);

}
}
?>