PHP 클래스를 사용하는 명령 줄 도구를 개발 중입니다. 나는 나의 수업에 대해 시험을 치렀다.PHPUnit 테스트 적용 범위가있는 명령 줄 스크립트
이제 커맨드 라인에서 사용한 PHP 스크립트를 테스트하고 싶습니다. 내가 명령 줄 스크립트 실행 라인을 커버 할 수있는 방법을 알고 싶습니다 How do I test a command-line program with PHPUnit?
:
나는 다음과 같은 스레드와 명령 줄을 유발하는 방법을 발견했다.
나는 등 테스트를 만들려고 :class CommandTest extends \PHPUnit_Framework_TestCase
{
protected static $command = './src/Command.php ';
protected static $testWorkingDir = 'tests/Command';
public function testCLIInstall()
{
$command = self::$command . ' --help';
$output = `$command`;
}
}
실행이 성공적으로 수행하지만 아무것도 파일 'Command.php'에서 커버하지 않습니다.
먼저 가능합니까? 그렇다면, 어떻게하면 커맨드 라인 스크립트 커버를 할 수 있습니까?
감사합니다.
최고 감사인,
Neoblaster.
업데이트 : GitHub의에서 문제를 엽니 다 https://github.com/sebastianbergmann/phpunit/issues/2817
안녕하세요 Marv255, 내 커맨드 라인 스크립트는 PHP 클래스가 아니지만 PHP 클래스를 사용합니다. 해당 스크립트를 찾으십시오 : [Command.php] (https://github.com/neooblaster/SYSLang/blob/master/src/Command.php?ts=3) 끝나지 않았지만 아마도 명령 줄 인터페이스를 만드는 잘못된 방법? 다음 줄을 어떻게 읽는 지 모르겠습니다. '(new Command ($ argv)) -> run()' – Neoblaster
또한, 내가 본 적이있는 PHP 용 명령 줄 스크립트를 만드는 가장 좋은 방법은 [symfony 콘솔] (https : // symfony.com/doc/current/components/console.html). 그것에 대해 더 자세히 알고 싶으시면 링크를 클릭하십시오. – marv255