Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run one file or map in phpunit

I'm using laravel and I've written some test files. But how can I exec only one file? When I do for example: phpunit tests/resulttesting/school/deleteSchoolForRealTest It throws an error:

Cannot open file "tests/resulttesting/school/deleteSchoolForRealTest.php".

When I run phpunit it runs all my tests. And how can I exec only one folder? I'm on a mac.

like image 314
Jamie Avatar asked Feb 24 '16 08:02

Jamie


People also ask

How do I run PHPUnit on Windows?

Open file Explorer and type "C:\windows\system32", then find cmd.exe and right click and select "Run as administrator". Start the Command Prompt as Administrator by clicking Start, All programs and Accessories, then right-click on Command Prompt link and selecting "Run as Administrator" from the context menu.

What is assertion in PHPUnit?

The assertSame() function is a builtin function in PHPUnit and is used to assert whether the actually obtained value is the same as the expected value or not. This assertion will return true in the case if the expected value is the same as the actual value else returns false.


2 Answers

You are doing everything correctly.

1)

First way to add folder. My correct way was:

phpunit tests/EWalletTest 

I had same errors when I forget to start from "tests" folder

phpunit EWalletTest 

I got

Cannot open file "EWalletTest.php".

2)

Filter is another option. read here example:

phpunit --filter EWallet 

Only runs tests whose name matches the given regular expression pattern.

Meaning that you will have executed files EWalletTest and EWalletFooTest and test cases from other file with names like `test_EWallet_with_Australian_dollar.

like image 200
Yevgeniy Afanasyev Avatar answered Sep 17 '22 14:09

Yevgeniy Afanasyev


Use filter option

phpunit --filter=EWalletTest 
like image 27
Mohammed Radwan Avatar answered Sep 21 '22 14:09

Mohammed Radwan