How to run single test method with phpunit?

前端 未结 13 2176
猫巷女王i
猫巷女王i 2020-11-30 16:13

I am struggling to run a single test method named testSaveAndDrop in the file escalation/EscalationGroupTest.php with phpunit. I tried

13条回答
  •  旧巷少年郎
    2020-11-30 17:08

    Here's the more generic answer:

    If you are sure the method name is unique you can only filter by method name (this works for me)

    phpunit --filter {TestMethodName}
    

    However it is safer to specify the file path/reference as well

    phpunit --filter {TestMethodName} {FilePath}
    

    Example:

    phpunit --filter testSaveAndDrop reference/to/escalation/EscalationGroupTest.php
    

    Quick note: I've noticed that if I have a function named testSave and another function named testSaveAndDrop using command phpunit --filter testSave will also run testSaveAndDrop and any other function that starts with testSave*, it's weird!!

提交回复
热议问题