By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,949 Members | 1,855 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,949 IT Pros & Developers. It's quick & easy.

Can't addFile() in SimpleTest Test Suite

P: n/a
Hey guys -

I have a test suite that's working when I include a test case via its
absolute path. For portability, I'd rather include it just using its
name, but it's failing with a "Failed to Open" error and I can't
figure out why. Hopefully someone more familiar with SimpleTest can
point me in the right direction (or point out my stupidity, as the
case may be).

Here are the highlights of my config:

- SimpleTest is installed in a support directory (~/projects/support/
simpletest) so that the framework can be used for multiple apps.

- The application is installed in ~/projects/work/myapp and its tests
are ~/projects/work/myapp/tests

- ~/projects/work/myapp/tests contains both all_tests.php and
my_test_case.php

- My include_path includes ~/projects/support/simpletest and "."

- all_tests.php looks like this:

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

class AllTests extends TestSuite {
public function AllTests() {
$this->TestSuite ( 'All tests' );
$this->addFile( 'my_test_case.php' );
}
}
?>

The error:

Warning: SimpleFileLoader::include_once(my_test_case.php)
[function.SimpleFileLoader-include-once]: failed to open stream: No
such file or directory in /home/myusername/projects/support/simpletest/
test_case.php on line 391

Warning: SimpleFileLoader::include_once() [function.include]: Failed
opening 'my_test_case.php' for inclusion (include_path='.:/usr/share/
php:/home/myusername/projects/work/shared-services/classes:/home/
myusername/projects/support/simpletest') in /home/myusername/projects/
support/simpletest/test_case.php on line 391

Warning: file_get_contents(my_test_case.php) [function.file-get-
contents]: failed to open stream: No such file or directory in /home/
myusername/projects/support/simpletest/test_case.php on line 428

Any thoughts would be much appreciated.

Thanks.

Rob
Sep 29 '08 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Woops. Sorry about the duplicate post. And crap. Just realized
what's probably happening. It's autorun.php that's probably trying to
do the include and that, of course, is failing. How do most folks
structure their environment? Clearly I'm doing it all wrong.

Thanks.
Sep 29 '08 #2

P: n/a
Rob Wilkerson wrote:
Woops. Sorry about the duplicate post. And crap. Just realized
what's probably happening. It's autorun.php that's probably trying to
do the include and that, of course, is failing. How do most folks
structure their environment? Clearly I'm doing it all wrong.

Thanks.
Use a relative path based off of the website root directory, which can
be found in $_SERVER['DOCUMENT_ROOT'].

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Sep 29 '08 #3

P: n/a
On Sep 29, 1:51*pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
Use a relative path based off of the website root directory, which can
be found in $_SERVER['DOCUMENT_ROOT'].
Thanks, Jerry. That worked of course:

$this->addFile( $_SERVER['DOCUMENT_ROOT'] . '/my_test_case.php' );

Is this pretty much the "standard" way of including files in a test
suite?
Sep 29 '08 #4

P: n/a
Rob Wilkerson wrote:
On Sep 29, 1:51 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
>Use a relative path based off of the website root directory, which can
be found in $_SERVER['DOCUMENT_ROOT'].

Thanks, Jerry. That worked of course:

$this->addFile( $_SERVER['DOCUMENT_ROOT'] . '/my_test_case.php' );

Is this pretty much the "standard" way of including files in a test
suite?
It's the way I do it - and a lot of other people I know. It makes
things easier - you can include the file without worrying about what
directory the including file is in.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Sep 29 '08 #5

P: n/a
On Sep 29, 4:02*pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
It's the way I do it - and a lot of other people I know. *It makes
things easier - you can include the file without worrying about what
directory the including file is in.
Fair enough. That works for me. Thanks for your help.
Sep 29 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.