How to exclude file from PHPUnit test suite in xml config?

前端 未结 7 652
夕颜
夕颜 2021-02-02 06:39

I have following, very simple, XML config for PHPUnit:


    
        

        
7条回答
  •  一个人的身影
    2021-02-02 07:28

    Along with the solutions above you could use more architecture-driven testing workflow where you manage your tests, directories and testsuites from phpunit.xml like this:

    • Group your tests in the directories (e.g. tests/Unit, tests/Feature);
    • Make testsuites as you see needed grouping your directories with element;
    • Make an All testsuite that combines all default tests you would run as a full test suite and assign it via defaultTestSuite="All" key within element.
    • Make a dedicated Tinker test suite with tests that you could use for tinkering, keeping example tests etc. you would exclude from normal testing workflow. Do not inlcude it in the All test suite.

    So you will be able to:

    • use phpunit CLI command to always run the default All tests.
    • use CLI to filter on testsuite, test file or single test level for any of your test suites e.g.:
      • phpunit --testsuite SuiteOne,
      • phpunit --filter SomeTest or
      • phpunit --filter SomeTest::test_some_test_method
      • combine --testsuite with --filter arguments

    Couple this workflow with the capability to run the current test or test file from within your IDE (for Sublime Text there are Mac and Linux/Windows plugins) and you will be completelly equipped to instantly chose what test to execute.

提交回复
热议问题