Summer Sale! All accounts are 50% off this week.

stephan-v's avatar

View succesful phpunit tests by their name?

Might be an easy question but I can't find it so far. I have written a couple of unit tests but I am wondering if there is a way to view which tests have run ok by their name in the commandline when you run phpunit. I would like to know which tests I am running exactly without looking at my test files constantly since I might be adding a whole bunch of them.

Cheers

0 likes
9 replies
SaeedPrez's avatar

@stephan-v

  • When you run phpunit it checks all files inside your tests folder that end with *Test.php and runs them all.
  • If you would like to limit testing to a single file, you could do phpunit tests/path/MyTest.php (tests\path\MyTest.php on Windows) and it will run all tests in that specific file only
  • If you would like to run a specific test (not a file), you can run phpunit --filter test_method_name

I hope this gives you an answer.

stephan-v's avatar

I know how it works, I simply want the names of the tests that are being ran visible in the commandline when I run phpunit from my commandline.

SaeedPrez's avatar

Great, I tried --verbose before and didn't think there was such option. I've learned something new today :) Thanks @gator

Edit: phpunit --tap outputs the tests too, in different format.

2 likes
stephan-v's avatar

I think I still like this one the best since it resembles the regular test the most, just found this between the other commands you guys gave me. Thanks for helping out!

phpunit --debug

1 like
SaeedPrez's avatar

So to sum it up.. there are 3 ways to accomplish this..

  1. phpunit --testdox
  2. phpunit --tap
  3. phpunit --debug
2 likes
davestewart's avatar

Love that testdox one. Weird name. Is it a play-on-words of "checkbox" ?

2 likes
qwertynik's avatar

--testdox looks neat!

Interestingly --testdox and --debug when passed together also work.

Please or to participate in this conversation.