David
David

Reputation: 165

how to install phpUnittest?

I am trying to write a Unit Test to test my YII application using phpunitest. I installed it and when I try to run my test I use shell command:

phpunit --bootstrap bootstrap.php DbTest.php

then I get this error:

PHPUnit 4.6.6 by Sebastian Bergmann and contributors.

Cannot open file "bootstrap.php".

how Can I fix this?

Upvotes: 1

Views: 84

Answers (2)

cn0047
cn0047

Reputation: 17061

This problem can be easily fixed.)
You should write correct path to your bootstrap.php. That's all.)

You can run phpunit --bootstrap boostrap.php SMTest.php only if your boostrap.php lies in same directory that SMTest.php.

Or you can write absolute paths:
phpunit --bootstrap /www/tests/config/boostrap.php /www/tests/unit/SMTest.php
and invoke this command from any place.

Upvotes: 1

j bee
j bee

Reputation: 86

your bootstrap goes in your phpunit.xml config file.

So it would look something like:

<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="bootstrap.php" colors="true">
</phpunit>

and when you run your test you run it with

phpunit --configuration=phpunit.xml

For reference: The phpunit.xml config section in the manual.

Upvotes: 0

Related Questions