0

I'm starting with tests in Laravel and now i can't reach my tests using phpunit.

The version of Laravel i'm using is 5.0.

OS is centos7 with php 5.6.

So, the first code i wrote is a duplicate of a existent function in the ExampleTest.php file, stored into "tests" folder, like this:

<?php

class ExampleTest extends TestCase {

 /**
  * A basic functional test example.
  *
  * @return void
  */
 public function testBasicExample()
 {
  //1 - verificando se a home devolve codigo 200
  $response = $this->call('GET', '/');
  $this->assertEquals(200, $response->getStatusCode());
 }

 public function testBasicExample2()
 {
  //1 - verificando se a home devolve codigo 200
  $response = $this->call('GET', '/');
  $this->assertEquals(200, $response->getStatusCode());
 }


}

This code is only for learning purposes and the goal here is make phpunit run both functions testBasicExample and testBasicExample2.

Te next step is running phpunit. In my case, i had to go to the vendor/phpunit directory and run command "php phpunit". Then, the command returned an error: Laravel 5 Failed opening required bootstrap/../vendor/autoload.php

So, i followed the best answer and i run "composer update" into terminal.

Ok, now i can run "php phpunit", but it run other tests and i can't see my exampletest return.

enter image description here

If some more data is needed, please just ask. Any help is apreciated.

Thanks in advance.

danielarend
  • 1,379
  • 13
  • 26

1 Answers1

2

You should run the binary from your project root:

cd /path/to/project/root
./vendor/bin/phpunit

This should automatically pick up the laravel included phpunit.xml configuration. If it does not work you can try running it as :

cd /path/to/project/root
./vendor/bin/phpunit --configuration /path/to/project/root/phpunit.xml
apokryfos
  • 38,771
  • 9
  • 70
  • 114