MakeGood and Composer need some fiddling to get them to work see
You might want to
- install phpunit with composer
- add a file MakeGoodPreload.php as your Preload Script in the MakeGood configuration.
- add phpunit.xml
More recent PHPUnit releases are optionally done with composer.
First install composer:
curl -sS https://getcomposer.org/installer | php
See https://phpunit.de/manual/current/en/installation.html
then install phpunit
php composer.phar require "phpunit/phpunit=4.8.*"
now test from the command line
vendor/phpunit/phpunit/phpunit.php test/MakeGoodTest.php
using the MakeGoodTest.php file below.
The result should be:
PHPUnit 4.8.21 by Sebastian Bergmann and contributors.
Warning: Deprecated configuration setting "strict" used
.
Time: 86 ms, Memory: 4.50Mb
OK (1 test, 5 assertions)
Recent MakeGood releases support the user of the composer installed phpunit.
In your Eclipse project create a project "makegood" that contains your
composer installation, test/MakeGoodTest.php, MakeGoodPreload.php and phpunit.xml.
Right click properties of the project and go to the "MakeGood" tab.
in the PHPUnit tab add phpunit.xml and in the General Tab set the Preload Script to MakeGoodPreload.php.
Now you should be able to open MakeGoodTest.php in the editor and right click to
get "Run Tests in class ...".
running it should give you:
PHPUnit 4.8.21 by Sebastian Bergmann and contributors.
Warning: Deprecated configuration setting "strict" used
.
MakeGood
[x] [32mPush and pop[39m
Time: 192 ms, Memory: 8.75Mb
OK (1 test, 5 assertions)
phpunit.xml
<phpunit backupGlobals="true"
backupStaticAttributes="false"
cacheTokens="false"
colors="false"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
forceCoversAnnotation="false"
mapTestClassNameToCoveredClassName="false"
printerClass="PHPUnit_TextUI_ResultPrinter"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
testSuiteLoaderClass="PHPUnit_Runner_StandardTestSuiteLoader"
strict="false"
verbose="false">
</phpunit>
MakeGoodPreload.php
<?php
// This is a preload script to be used with
// the Eclipse makegood continuous integration plugin
// see https://github.com/piece/makegood/releases
error_reporting(E_ALL);
$loader = require 'vendor/autoload.php';
test/MakeGoodTest.php
<?php
class MakeGoodTest extends PHPUnit_Framework_TestCase
{
public function testPushAndPop()
{
$stack = array();
$this->assertEquals(0, count($stack));
array_push($stack, 'foo');
$this->assertEquals('foo', $stack[count($stack)-1]);
$this->assertEquals(1, count($stack));
$this->assertEquals('foo', array_pop($stack));
$this->assertEquals(0, count($stack));
}
}
?>