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.

1 Answer 1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.