1

What is this error? How to create simple test in laravel.

PHPUnit 6.3.1 by Sebastian Bergmann and contributors.

Time: 130 ms, Memory: 4.00MB

No tests executed!

tests/Feature/ReadArticle.php

<?php

namespace Tests\Feature;

use Tests\TestCase;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;

class ReadArticle extends TestCase
{
    /**
     * @test
     */
    public function a_user_can_view_home_page()
    {
        $this->get('/')->assertSee('وبسایت اکسبیر');
    }
}
  • how you run the test? what is the command you executed? – Shiro Dec 28 '17 at 12:07
  • composer global require phpunit/phpunit –  Dec 28 '17 at 12:20
  • Possible duplicate of [PHPUnit - 'No tests executed' when using configuration file](https://stackoverflow.com/questions/29299206/phpunit-no-tests-executed-when-using-configuration-file) – Adam Kozlowski Dec 28 '17 at 12:39
  • run `./vendor/bin/phpunit` in your project folder. The version from your global phpunit might not same as your project require version. – Shiro Dec 28 '17 at 15:51

2 Answers2

9

If you used cmd line enter: "./vendor/bin/phpunit" to the root application. Don't forget about quotes!

grantDEV
  • 552
  • 1
  • 6
  • 10
4

2 possibilities :

Your test have to be

class ReadArticleTest extends TestCase

And so is your file name

You might use your global PHPunit instead of the laravel one.

Try this :

./vendor/bin/phpunit
Mathieu Ferre
  • 4,246
  • 1
  • 14
  • 31