Page 1 of 1

Help needed installing SimpleTest

Posted: Sun Jul 22, 2007 7:48 am
by giles
Hi all,

I just starting to learn about testing PHP. I’ve downloaded SimpleTest but I can’t find any details on instillation. I’ve tried uploading the the source simpleTest folder to me server root ... some tests work but most don’t, don’t really know where to go from here :cry: . Can you help?

Thanks
Giles

Re: Help needed installing SimpleTest

Posted: Sun Jul 22, 2007 7:58 am
by lastcraft
Hi...
giles wrote:I’ve downloaded SimpleTest but I can’t find any details on instillation. I’ve tried uploading the the source simpleTest folder to me server root ... some tests work but most don’t, don’t really know where to go from here :cry:
There is no installtion as such, it just runs straight away. Documentation is bundled, as well as present on the website. Check your docs folder in the tarball.

Create a do nothing test script (a sort of hello world)...

Code: Select all

<?php
require_once('simpletest/autorun.php');

class HelloWorld extends UnitTestCase {
    function testWeGetOnePass() {
        $this->assertTrue(true);
    }
}
?>
The autorun stuff is new, and will save you a few lines of code over the tutorial examples.

When you point the browser at this script, you should get a green bar. When you run the script on the command line you should get a few lines of explanation that include "OK".

What happens?

yours, Marcus

Re: Help needed installing SimpleTest

Posted: Sun Jul 22, 2007 8:53 am
by giles
Hi Marcus,

Thanks for your reply. I've tried your example without much luck. Results in a blanc window (not even a fail). This is what I'm getting when I run the majority of tests in the simpleTest folder (though a few like simpletest/test/command_line_test.php do work)

Posted: Sun Jul 22, 2007 9:35 am
by lastcraft
Hi...

Do you have errors displayed in your php.ini file? Clearly something has gone horribly wrong, but we cannot see the failure messages.

yours, Marcus

Posted: Sun Jul 22, 2007 1:02 pm
by giles
Thanks for the prompt. I've fixed "hello_world" by appenting line 2 to

Code: Select all

require_once dirname(__FILE__) . '/autorun.php';
- it now works fine. However I'm still getting errors when I run individual tests such as :
Fail: Two bad test cases -> /pathToMyRoot/simpletest/test/support/empty_test_file.php -> Bad TestSuite [/pathToMyRoot/simpletest/test/support/empty_test_file.php] with error [No runnable test cases in [/pathToMyRoot/simpletest/test/support/empty_test_file.php]]
in the test bad_test_suite.php. Thing is ... I havnt changed any of the file structure of the SimpleTest directory that I downloaded, so what I'm wondering what paramiters on my server coud be set incorrectly to upset PARTS of SimpleTest. Ive assigned 16 meg to php ... is there anything else I need to check?

Posted: Sun Jul 22, 2007 1:42 pm
by lastcraft
Hi...

You don't run that one directly. It's just a little visual one that I can use to make sure bad file loads throw errors in SimpleTest. I keep meaning to move it to the samples folder, but just haven't got around to doing it.

The only tests you really need to run as a new user are all_tests.php if you are connected to the net, or unit_tests.php if you aren't. Are they green?

yours, Marcus

Posted: Sun Jul 22, 2007 2:14 pm
by giles
Yeah got it, moved a copy there myself and also worked fine - so SimpleTest appears to be working fine with that example (thank you).

Your next comment re all_tests.php. This is where my problems start! Running all_tests.php with error display on still results in a blanc screen. Running the individual tests (to try and break problem down) results in a mixed bag of results!

acceptance_test.php
- stalls, with my server timing out

adapter_test.php
- works

authentication_test.php
- returns an error message of
Fatal error: Call to undefined method ReflectionClass::hasMethod() in /pathToMyRoot/simpletest/reflection_php5.php on line 223
- BUT simpleTest now works returning a message of
Fail: -> Bad TestSuite [authentication_test.php] with error [No runnable test cases in [authentication_test.php]]

Just to clarify;
- I downloaded SimpleTest 1.0.1 beta 2
- uploaded the extracted directory into the root of my web server
- I'm running Fedora Core 4 / Apache 2.0.54

Posted: Sun Jul 22, 2007 6:43 pm
by lastcraft
Hi...

OK, what happens when you run unit_tests.php?

The acceptance tests might indeed time out if something is a bit slow in your network stack. I would increase the php.ini script time and see what happens. You could also try the tests from the command line. They often run faster in this environment.

I don't understand why authentication_test.php should fail. I'll investigate this.

yours, Marcus

Posted: Mon Jul 23, 2007 9:20 pm
by giles
Hi Marcus,

not good I'm afraid pointing my browser to unit_tests.php returns
Fatal error: Call to undefined method ReflectionClass::hasMethod() in /pathToRoot/simpletest/reflection_php5.php on line 223
I'll give the command line angle a go and get back to you when I've given it a try. In passing - is there anything obvious like directory location, incorrect privalage set could be causing this?

Best Giles

Posted: Tue Jul 24, 2007 3:10 am
by lastcraft
Hi...

Which version of PHP are you using? A language dependency may have crept in.

yours, Marcus

Posted: Tue Jul 24, 2007 5:51 am
by giles
Hi

- PHP v5.0.4
- running on Red Hat Fedora Core 4

do you need to know anything else?

Best
Giles

Posted: Wed Jul 25, 2007 3:44 pm
by giles
Hey Marcus, a bit of good news .... acceptance_test.php runs with command line returning

Code: Select all

Test cases run: 16/17, Passes: 591, Failures: 0, Exceptions: 0
but sadly not with unit_tests.php, returning same error as above.