I'm trying to execute the PHPUnit test but the PHPUnit doesn't read any tests in my file:
hm@BP_PC3:/mnt/c/MAMP/htdocs$ phpunit
PHPUnit 6.0.10 by Sebastian Bergmann and contributors.
Time: 126 ms, Memory: 8.00MB
No tests executed!
But when i run ./vendor/bin/phpunit then i see the following output:
PHP Fatal error: Class 'PHPUnit_Framework_TestCase' not found in /mnt/c/MAMP/htdocs/test/unit/CalcTest.php on line 5
I have configured my file like this:
<?xml version="1.0" encoding="UTF-8" ?>
<phpunit bootstrap="./vendor/autoload.php"
color="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnFailures="false"
syntaxCheck="false">
<testsuites>
<testsuite name="PHPUnit Tuts">
<directory>test</directory>
</testsuite>
</testsuites>
</phpunit>
And thats the structure:
app - lib - calculator.php
|
test - unit - CalcTest.php
|
vendor - bin - (standard files)
|
composer.json
composer.lock
phpunit.xml
composer.json:
{
"autoload": {
"psr-4": {
"App\\": "app"
}
},
"autoload-dev": {
"files": ["test/unit/CalcTest.php"]
},
"require-dev" : {
"phpunit/phpunit": "^6.0"
}
}
And this is how my CalcTest.php looks like, actually very standard:
<?php
require_once 'PHPUnit/Autoload.php';
class CalcTest extends \PHPUnit_Framework_TestCase {
public function testAdd() {
$this->assertTrue(true);
}
}
?>
I have tried to delete the line "files" in composer.json and it didn't work either.