Page 1 of 1
Simpletest download
Posted: Fri Apr 18, 2008 3:30 pm
by matthijs
Ok, I'm tired of searching and trying to debug things so I'll ask here: can someone provide me with a Simpletest version that runs on php 5.2.5?
I downloaded the last release, I checked out from svn on sourceforge but can't get anything running properly.
Re: Simpletest download
Posted: Fri Apr 18, 2008 7:59 pm
by Chris Corbyn
The code in subversion is E_STRICT:
Code: Select all
svn co https://simpletest.svn.sourceforge.net/ ... test/trunk simpletest
The latest download on sourceforge works with PHP5, but not under E_STRICT.
Re: Simpletest download
Posted: Sat Apr 19, 2008 12:41 am
by matthijs
I have checked out exactly that version. But there is so much changed, I can't get it working. The accompanying HELP_MY_TESTS_DONT_WORK_ANYMORE help file is also very confusing, the info in it doesn't make sense with what's in the checkout.
Re: Simpletest download
Posted: Sat Apr 19, 2008 2:29 am
by Chris Corbyn
Don't read that file

That only really applies to experience SimpleTest users who my have used way older versions.
Once you've checked out the code, create a file called "test.php" somewhere in your web root. Inside it, put these contents:
test.php
Code: Select all
<?php
require_once '/path/to/simpletest/unit_tester.php';
require_once '/path/to/simpletest/reporter.php';
class MyTest extends UnitTestCase {
public function testNothing() {
$this->assertFalse(true, 'Just a failing nothing test');
}
}
$test = new MyTest();
$test->run(new HtmlReporter());
What do you get if you run that in your web browser?
Re: Simpletest download
Posted: Sat Apr 19, 2008 3:35 am
by matthijs
Brilliant! That runs fine. Thanks. So now I know at least that it does work.
The problem then is to convert my existing test setup to run. It's the test setup Arborint made for the Skeleton
Code: Select all
<?php
ini_set('error_reporting', E_ALL | E_STRICT);
require_once('config.php');
require_once(SIMPLETESTDIR . 'simpletest.php');
require_once(SIMPLETESTDIR . 'unit_tester.php');
require_once(SIMPLETESTDIR . 'reporter.php');
if (isset($_GET['test']) && file_exists($_GET['test'])) {
$testfile = $_GET['test'];
$title = "Test File $testfile";
} else {
$testfile = '';
$title = 'All Test Files';
}
$test = &new GroupTest($title);
if ($testfile) {
$test->addTestFile($_GET['test']);
} else {
foreach(glob(dirname(__FILE__) . '/*_test.php') as $testfile) {
$test->addTestFile($testfile);
}
}
if (TextReporter::inCli()) {
$test->run(new TextReporter());
} else {
$test->run(new HtmlReporter());
}
Running this will lead to
Fatal error: Class 'GroupTest' not found in /Users/matthijs/Sites/skeleton/tests/all_tests.php on line 16
From this situation, starting to follow the instructions in the help file only leads to more errors:
Replacing the line
$test = &new GroupTest($title);
with
$test = &new TestSuite($title);
leads to
Fatal error: Call to undefined method TestSuite::addTestFile() in /Users/matthijs/Sites/skeleton/tests/all_tests.php on line 22
There's nothing in the help file about this error.
In the mean time I did get the old version (the download) to work, so maybe I should just use that. But it's too bad it doesn't run E-strict, something I would like.
Re: Simpletest download
Posted: Sat Apr 19, 2008 9:15 pm
by Chris Corbyn
I stopped using GroupTest and TestSuite because of memory issues and because it's easier to have a fresh test environment for each test if you run each test indivudually. My custom built suite is a little complex however but I plan on tidying it up and releasing it.
You want $suite->addFile(...) as opposed to addTestFile( ... ).
Re: Simpletest download
Posted: Sun Apr 20, 2008 1:17 am
by matthijs
Ok, nice to know. Thanks for your reply. As Arborint put it together is nice because if a testfile is selected it runs that single test, otherwise it will run all tests. But I can imagine that if your tests gets larger you'd wan to run them individually.