특정 phpunit xml 테스트 스위트를 실행하는 방법은?
실행할 특정 테스트 제품군을 어떻게 선택할 수 있습니까?
$ phpunit --configuration config.xml
config.xml:
<testsuites>
<testsuite name="Library">
<directory>library</directory>
</testsuite>
<testsuite name="XXX_Form">
<file>library/XXX/FormTest.php</file>
<directory>library/XXX/Form</directory>
</testsuite>
</testsuites>
PHP Unit 3.7.13처럼 코드가 있습니다.
$ phpunit --configuration config.xml --testsuite Library
$ phpunit --configuration config.xml --testsuite XXX_Form
테스트 스위트 그룹을 실행하려면 이 작업을 수행할 수 있습니다.
<testsuites>
<testsuite name="Library">
<directory>library</directory>
</testsuite>
<testsuite name="XXX_Form">
<file>library/XXX/FormTest.php</file>
<directory>library/XXX/Form</directory>
</testsuite>
<testsuite name="Both">
<directory>library</directory>
<file>library/XXX/FormTest.php</file>
<directory>library/XXX/Form</directory>
</testsuite>
</testsuites>
그리고나서
$ phpunit --configuration config.xml --testsuite Both
안타깝게도 PHPuit는 현재 이와 같은 중첩 테스트 제품을 지원하지 않습니다.
<testsuites>
<testsuite name="Both">
<testsuite name="Library">
<directory>library</directory>
</testsuite>
<testsuite name="XXX_Form">
<file>library/XXX/FormTest.php</file>
<directory>library/XXX/Form</directory>
</testsuite>
</testsuite>
</testsuites>
따라서 테스트 스위트 그룹을 이러한 방식으로 실행하려면 xml 구성 복제가 필요합니다.
현재 버전의 PHPUnit에서는 phpunit-user mailing list: http://thread.gmane.org/gmane.comp.php.phpunit.user/1302 에서 이 메시지를 증명할 수 없습니다.
하지만 대안이 하나 있는데, 단순히 pphunit로 경로를 전달하면 됩니다.
phpunit library/XXX
이렇게 하면 라이브러리/XXX 디렉토리에서 모든 테스트가 실행됩니다.
이 방법으로 충분하지 않은 경우 @group 주석을 사용하여 검정을 선택적으로 실행할 수 있는 여러 범주로 나누는 것도 방법입니다.
phpunit 6.1 현재 당신은 xml config 파일에서 속성을 사용할 수 있습니다.defaultTestSuite, 기본 옵션을 사용하는 것과 같습니다.phpunit --testsuite xxx과식하고 있습니다.
또 다른 옵션은 테스트하려는 각 테스트 제품군에 대해 별도의 구성 파일을 만드는 것입니다.중복 설정을 복사/붙여넣어야 한다는 점에서 오버헤드가 있지만 필요에 따라 각 구성 파일을 지정할 수 있습니다.
여기 있는 다른 답들은 맞습니다.xml config로 할 수는 없지만, pph로 같은 종류의 config를 만드는 것이 가능합니다.
가장 예쁜 것은 아니지만 필요한 기능을 제공할 수 있을 것입니다.
xml 구성을 제공했습니다.
<testsuites>
<testsuite name="Library">
<directory>library</directory>
</testsuite>
<testsuite name="XXX_Form">
<file>library/XXX/FormTest.php</file>
<directory>library/XXX/Form</directory>
</testsuite>
</testsuites>
가상적으로, 당신의 디렉토리 "라이브러리"에 3개의 파일이 있다고 가정해 보겠습니다.
library
XXX
FormTest.php
Unit
unittest1.php
unittest2.php
그리고 각 파일에 완벽한 이름 지정 규칙에 의해 하나의 테스트가 포함되어 있습니다. 예: FormTest에는 testForm()이 포함되어 있습니다.
구성의 경우 다음 내용을 모두 포함하는 구성을 만듭니다.
<?php
include_once "library/XXX/FormTest.php";
include_once "library/Unit/unittest1.php";
include_once "library/Unit/unittest2.php";
그럼 pphunit naming 규약으로 클래스를 만들겠습니다.이름은 마음대로 지어도 돼요. 우리는 절대 사용하지 않을 테니까요.
class LibraryConfigTest extends PHPUnit_Framework_TestCase {
각 "테스트 스위트"는 단순히 원하는 테스트를 실행하는 방법입니다.원하는 대로 방법을 말씀해 주십시오. 다시 한번, 우리는 그것을 실제로 사용하지 않을 것입니다.Pphunit이 실행을 처리할 것입니다.실행 방법을 알 수 있도록 그룹별로 코멘트를 달아야 합니다.
/**
* All Tests in Library
* @group Library
**/
public function testLibrary() {
UnitTest1::testUnit1();
UnitTest2::testUnit2();
FormTest::testForm();
}
/**
* All Form tests in library/XXX
* @group XXX_Form
**/
public function testForm() {
FormTest::testForm();
}
}
?>
이제 원하는 기능을 얻으려면 원하는 그룹에 대해 "config"를 실행하면 됩니다.
phpunit --group XXX_Form library_config.php
phpunit --group Library library_config.php
말씀드린 것처럼, 지속적인 유지보수가 필요하기 때문에 이 코드는 보기 흉하고 분명 좋지 않지만, 여러분이 찾고 있는 기능을 제공해 줄 것입니다.
Bergmann이 다음 라운드에서 이 기능을 추가하기를 바랍니다. 비록 그가 그것을 거의 무시하고 있는 것처럼 보이지는 않지만 말입니다.
언급URL : https://stackoverflow.com/questions/3671685/how-to-run-a-specific-phpunit-xml-testsuite
'programing' 카테고리의 다른 글
| 빈도순으로 상위 구별 결과 선택 (0) | 2023.09.16 |
|---|---|
| "'필드 목록'에 알 수 없는 열"이 있지만 열이 존재합니다. (0) | 2023.09.16 |
| 장고: 양식을 사용하여 하나의 템플릿에 여러 개의 모델을 사용합니다. (0) | 2023.09.16 |
| c, boole에서 true == 1이고 false == 0입니까? (0) | 2023.09.16 |
| 경고: refname''HEAD'는 애매합니다. (0) | 2023.09.16 |