Created
August 12, 2014 05:28
-
-
Save abdullahbutt/745588042439c9777158 to your computer and use it in GitHub Desktop.
laravel running an initial test with phpunit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Running an initial test with phpUnit | |
//first use shortky below to set phpunit in composer wit below command | |
doskey phpunit=vendor\bin\phpunit $* | |
//then test phpunit functionality with below command in composer but typing the help function below | |
phpunit -h | |
// Then run the "ExampleTest.php" with below command in composer, giving the path of test file "EampleTest.php": | |
phpunit app/tests/ExampleTest.php | |
//Below is how it will look like in Composer after running the test command: | |
C:\Abdullah\Laravel\projects\authapp>phpunit app/tests/ExampleTest.php | |
PHPUnit 4.2.0 by Sebastian Bergmann. | |
Configuration read from C:\Abdullah\Laravel\projects\authapp\phpunit.xml | |
. | |
Time: 380 ms, Memory: 10.75Mb | |
<-30;42mOK (1 test, 1 assertion)<-[0m | |
//Note: There is a "." belween "Configuration read..." and "Time: ...." This "." shows that 1 test was run | |
// Below is the view if the test fails: We will give path of "TestCase.php" which is not actually a test case & | |
hence test will fail: | |
C:\Abdullah\Laravel\projects\authapp>phpunit app/tests/TestCase.php | |
PHPUnit 4.2.0 by Sebastian Bergmann. | |
Configuration read from C:\Abdullah\Laravel\projects\authapp\phpunit.xml | |
<-[41;37mF<-[0m | |
Time: 111 ms, Memory: 9.00Mb | |
There was 1 failure: | |
1) Warning | |
No tests found in class "TestCase". | |
<-[37;41m <-[0m | |
<-[37;41mFAILURES! <-[0m | |
<-[37;41mTests: 1, Assertions: 0, Failures: 1.<-[0m | |
// Now to set up a new test case, copy "ExampleTest.php" in tests folder and rename it to "TrueTest.php" | |
// Also rename the public function to "public function testTrue()" & update below test using assertTrue | |
public function testTrue() | |
{ | |
$theTruth=true; | |
$this->assertTrue($theTruth); | |
} | |
// Then run the "TrueTest.php" in phpunit with below command: | |
phpunit app/tests/TrueTest.php | |
// It will look like below in composer: | |
C:\Abdullah\Laravel\projects\authapp>phpunit app/tests/TrueTest.php | |
PHPUnit 4.2.0 by Sebastian Bergmann. | |
Configuration read from C:\Abdullah\Laravel\projects\authapp\phpunit.xml | |
. | |
Time: 172 ms, Memory: 10.25Mb | |
<-[30;42mOK (1 test, 1 assertion)<-[0m | |
C:\Abdullah\Laravel\projects\authapp> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment