Simpletest download

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
matthijs
DevNet Master
Posts: 3360
Joined: Thu Oct 06, 2005 3:57 pm

Simpletest download

Post 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.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Simpletest download

Post 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.
matthijs
DevNet Master
Posts: 3360
Joined: Thu Oct 06, 2005 3:57 pm

Re: Simpletest download

Post 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.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Simpletest download

Post 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?
matthijs
DevNet Master
Posts: 3360
Joined: Thu Oct 06, 2005 3:57 pm

Re: Simpletest download

Post 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.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Simpletest download

Post 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( ... ).
matthijs
DevNet Master
Posts: 3360
Joined: Thu Oct 06, 2005 3:57 pm

Re: Simpletest download

Post 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.
Post Reply