|
From: Mark D. <mar...@hp...> - 2008-08-18 23:05:46
|
Marcus Baker wrote:
> Hi...
>
> Mark Donohoe wrote:
>> I also tried to have the above classes extend fossologyWebTestCase instead of
>> WebTestCase, but still get the same failure?
>> ...
>
> This is going to nearly impossible to sort out via e-mail. Can you send
> me an example failing test case, with as small amount of code as
> necessary to duplicate your problem? I can debug it quickly and easily
> if I can play with real code. Most of what you describe *should* work fine.
>
>> What am I missing, how do I do this? Thanks for your time and help.
Marcus,
Thanks for your time... I thought it should work, I was starting to feel really
dumb! Here is the code I used, I actually tried this when I tried refactoring,
since that attempt failed I went to a simple example to see if that would work
when it didn't I posted.
Below is the code, it's as small as I could make it and represent what I was
trying to do. I need to read the second part of your message to see how that
will help, as that might also help with my testing.
1. fossWebTestCase.php
<?php
if (!defined('SIMPLE_TEST'))
define('SIMPLE_TEST', '/usr/local/simpletest/');
/* simpletest includes */
require_once SIMPLE_TEST . 'unit_tester.php';
require_once SIMPLE_TEST . 'reporter.php';
require_once SIMPLE_TEST . 'web_tester.php';
class fossWebTestCase extends WebTestCase
{
public $mybrowser;
public $debug;
public function funcTrue() { return(TRUE); }
public function funcFalse() { return(FALSE); }
public function someTest()
{
print "starting someTest\n";
if($this->debug)
{
print "Checking /tmp\n";
}
$this->assertTrue(is_dir('/tmp'));
$this->assertTrue($this->get('http://www.hp.com'));
}
}
?>
2. the run script: 'runexp.php
#!/usr/bin/php
<?php
require_once('/usr/local/simpletest/web_tester.php');
require_once '/usr/local/simpletest/reporter.php';
require_once ('fossWebTestCase.php');
/**
* stub to run lib tests
* Created on Aug 18, 2008
*/
$test = &new TestSuite('Experiment for test libraries');
$test->addFile('exp1.php');
$test->addFile('exp2.php');
$test->addTestFile('exfoss.php');
if (TextReporter::inCli())
{
exit ($test->run(new TextReporter()) ? 0 : 1);
}
$test->run(new HtmlReporter());
?>
The Test: exfoss.php
<?php
require_once('fossWebTestCase.php');
class expfoss extends fossWebTestCase
{
function testexpfoss()
{
print "running expfoss\n";
print "using sometest from fossWebTestCase\n";
$this->someTest();
print "trying to use exp2::doaTest\n";
$this->doaTest();
print "trying to use exp1::guess\n";
assertTrue($this->guess(7)); // should pass
assertTrue($this->guess(10)); // should fail
}
}
?>
Test libraries: (well that's what I'm currently calling them)....
1. exp1.php
<?php
class exp1tester extends fossWebTestCase
{
public $answer = 7;
function guessTest($guess)
{
print "guessTest is running\n";
$this->assertTrue($this->get('http://fossology.org/'));
$this->assertText('Fossology Mission');
if($answer == $guess){
print "You guessed the answer! it is $answer\n";
return TRUE;
}
else {
print "Sorry! Incorrect guess, try again\n";
return FALSE;
}
}
}
Second lib file: exp2.php
<?php
require_once('fossWebTestCase.php');
class exp2tester extends fossWebTestCase
{
function doaTest()
{
print "doaTest is running\n";
$this->assertTrue($this->get('http://www.lastcraft.com/'));
$this->assertText('Why the last craft');
}
}
?>
Output:
./runexp.php
Experiment for test libraries
running expfoss
using sometest from fossWebTestCase
starting someTest
trying to use exp2::doaTest
Fatal error: Call to undefined method expfoss::doaTest() in
/home/markd/Src/fossology/tests/testClasses/exfoss.php on line 17
markd@snape:
The line number of the failure is incorrect, I chopped some more comments to
make the code smaller.
This being run on a debian etch system, using PHP version PHP 5.2.0-8+etch11
(cli) and using simpletest_1.0.1.
BTW, I was serious about helping with the documents. My job will allow me some
time to do so and I can devote some of my personal time as well. I really like
your project and want to help make it even easier to use. I have notes about
the current docs. Should I just file a defect report via Source Forge or post
them somewhere?
Thanks again for your time.
--
Mark Donohoe
OSLO/OSTT, Cupertino CA.
fossology.org
|