Running a single test with PHPStorm opens it in the browser
Answered
Hi,
I'm having a problem here with PHPUnit testing on PHPStorm. When clicking 'Run' the tests directory, it does what I expect and runs it as a test. But when I click 'Run' on a single test file, it opens it in the browser instead of running it as a test.
How can I configure PHPStorm to run those files as tests so I can run a single test and not the whole suite every time?
Thank's, Daniel.
Please sign in to leave a comment.
>Right-Click on the php file and then Run.
Sorry for not being more clear. I want screenshot of that -- the content menu item that you are clicking on.
Your PHPUnit configurations are fine.
You see -- you do have JavaScript Debug configuration named "ViewConcertsListingTest.php" -- most likely it's what you are clicking via context menu.
"The devil is in details" -- in your case it's the icon next to the "Run" button. Most likely it will be the same as that JavaScript configuration has .. and not PHPUnit one.
Hi there,
Screenshots please.
You might be doing something wrong ... or it tries to run previously created (temp) Run/Debug Configuration that is of "PHPUnit by HTTP" or something like that.
Use "Run | Edit Configurations..." or drop-down box on toolbar (next to Run/Debug buttons) to check your existing configurations.
This 1 screenshot looks OK for me.
Could you please illustrate what and where do you click when you run that "single test"?
Right-Click on the php file and then Run. For some reason it works fine for ConcertTest.php (Unit folder), but ViewConcertsListingTest.php (Feature folder) opens in the browser. Both configurations are identical to the one I posted above (except for the Directory field of course).
I'm sorry .. but I want to see the screenshot. There is a chance that whatever you are clicking there is not related to actual PHPUnit at all... and screenshot should clarify that.
Thank's!
I had the same problem, and the the resolution above worked. It's worth to note the root cause was that the class I was trying to 'run' did not extend the base `TestCase` class, thus could not be tested by phpunit.