2

Using PhpUnit 6.3 to test a helloWorld() function written in PHP 7.1. The test runs ok if I execute its php file directly from the command line:

> php C:\path\to\phpunit.phar C:\project\hello-world\hello-world_tests.php
  OK <1 test, 1 assertion>

However if I rely on my configuration file, no test is run:

> php C:\path\to\phpunit.phar --configuration C:\project\phpunit.xml
  No tests executed!

Here is my folder structure:

project/
    phpunit.xml
    phpunit.phar
    hello-world/
        hello-world.php
        hello-world_test.php

Here is my configuration file, phpunit.xml:

<phpunit>
    <testsuites>
        <testsuite name="Test suite">
            <directory>./hello-world</directory>
        </testsuite>
    </testsuites>
</phpunit>

Replacing the directory node with a file node gets things working:

<file>./hello-world/hello-world_test.php</file>

that's nice, but I don't want to list all test files individually, which is why I had the directory node originally.

1
  • AFAIR PHPUnit picks up only files named with trailing Test at the end -- making it to be helloWorldTest.php if to include file extenstion. Commented Sep 3, 2017 at 17:56

1 Answer 1

2
<phpunit>
    <testsuites>
        <testsuite name="Test suite">
            <directory suffix="_test.php">./hello-world</directory>
        </testsuite>
    </testsuites>
</phpunit>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.