我的工作台中有一个包,我想开始测试。
在目录中运行phpunit会加载phpunit.xml文件并获取测试类。然而,它崩溃了,因为它无法找到我的包服务提供商。
Fatal error: Class 'Appointedd\Appointedd\AppointeddServiceProvider' not found in /Library/WebServer/Documents/appointedd-microsites/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php on line 158
phpunit.xml
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="../../../vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
>
<testsuites>
<testsuite name="Package Test Suite">
<directory suffix=".php">./tests/</directory>
</testsuite>
</testsuites>
</phpunit>
我的测试班:
<?php
error_reporting(E_ALL); ini_set('display_errors', 1);
class AppointeddTest extends \Illuminate\Foundation\Testing\TestCase {
public function createApplication() {
$unitTesting = true;
$testEnvironment = 'testing';
return require __DIR__.'/../../../../bootstrap/start.php';
}
public function testSomething() {
$this->assertTrue(true);
}
}
目录结构:
/workbend/appointedd/appointedd/
src/
Appointedd/Appointedd/
Appointedd.php
AppointeddServiceProvider.php
Facades/
Appointedd.php
tests/
AppointeddTest.php
phpunit.xml