mercredi 21 janvier 2015

How to execute all tests in PHPUnit?

I'm trying run all tests from my testsuite, but PHPUnit not found the tests when I run command phpunit. I config testsuite in phpunit.xml.


phpunit.xml



<?xml version="1.0" encoding="UTF-8" ?>
<phpunit backupGlobals="true"
backupStaticAttributes="false"
bootstrap="./bootstrap.php"
cacheTokens="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
forceCoversAnnotation="false"
mapTestClassNameToCoveredClassName="false"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
strict="false"
verbose="true">
<testsuites>
<testsuite name="All Tests">
<directory suffix="*.php">.</directory>
</testsuite>
</testsuites>
</phpunit>


bootstrap.php



<?php

error_reporting(E_ALL | E_STRICT);
date_default_timezone_set('America/Sao_Paulo');
require_once(dirname(__FILE__) . '/WebTestCase.php');


WebTestCase.php



<?php

define('TEST_BASE_URL', 'http://localhost:8080');

class WebTestCase extends PHPUnit_Extensions_SeleniumTestCase
{

protected function setUp() {
$this->setBrowser('*firefox');
$this->setBrowserUrl(TEST_BASE_URL);
$this->setHost('localhost');
$this->setTimeOut(30);
}
}


TestPage.php



class TestPage extends WebTestCase
{

public function testTitle()
{
$this->open("/");
$title = $this->getTitle();
$this->assertEquals('Home', $title);
}
}


If I run phpunit passing file test, as phpunit TestPage.php, is ok.


enter image description here


Aucun commentaire:

Enregistrer un commentaire