php - 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?




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

You can runphpunit --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.




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">

and when you run your test you run it with

phpunit --configuration=phpunit.xml

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

People are also looking for solutions to the problem: php - Strict Standards: Declaration of RPA::PreLoadField() should be compatible with that of Foundation::PreLoadField()


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.