Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

LadyC's avatar
Level 1

Laravel 5.6 Testing - No tests executed!

Hi, I've to rectify what I said in this post.

Premises

I'm using Laravel 5.6 within XAMPP in a Windows 10 machine. I've created from scratch a laravel application. At the beginning I've implemented a dusk testing, then I've deleted the folder and recreated (from backup).

I'm usign vendor/bin/phpunit, but I've also tried with vendor/phpunit/phpunit/phpunit. Same result.

Problem

I'm trying to set up some phpunit testing, but I received the message "No tests executed!".

Code

My Composer json:


{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": "^7.1.3",
        "barryvdh/laravel-ide-helper": "^2.4",
        "fideloper/proxy": "^4.0",
        "laravel/browser-kit-testing": "4.0.x-dev",
        "laravel/dusk": "^3.0",
        "laravel/framework": "5.6.*",
        "laravel/tinker": "^1.0",
        "nexmo/client": "1.3.2",
        "nexmo/laravel": "1.1.1",
        "phpunit/phpunit": "7.1.5"
    },
    "require-dev": {
        "filp/whoops": "^2.0",
        "fzaninotto/faker": "^1.4",
        "mockery/mockery": "^1.0",
        "nunomaduro/collision": "^2.0"
    },
    "autoload": {
        "classmap": [
            "database/seeds",
            "database/factories"
        ],
        "psr-4": {
            "App\": "app/",
            "Todo\": "app/Repositories/Todo/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\": "tests/"
        }
    },
    "extra": {
        "laravel": {
            "dont-discover": [
            ]
        }
    },
    "scripts": {
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate"
        ],
        "post-autoload-dump": [
            "Illuminate\Foundation\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover"
        ]
    },
    "config": {
        "preferred-install": "dist",
        "sort-packages": true,
        "optimize-autoloader": true
    },
    "minimum-stability": "dev",
    "prefer-stable": true
}

My phpunit.xml:

<?xml version="1.0" encoding="UTF-8"?>
<phpunit verbose="true"
         bootstrap="vendor/autoload.php"
         colors="true"
         backupGlobals="false"
         backupStaticAttributes="false"
         convertErrorsToExceptions="true"
         convertNoticesToExceptions="true"
         convertWarningsToExceptions="true"
         processIsolation="false"
         stopOnFailure="false">

    <testsuites>
        <testsuite name="Unit">
            <directory suffix="Test.php">tests/Unit</directory>
        </testsuite>
        <testsuite name="Feature">
            <directory suffix="Test.php">tests/Feature</directory>
        </testsuite>
    </testsuites>

    <filter>
        <whitelist processUncoveredFilesFromWhitelist="true">
            <directory suffix=".php">./app</directory>
        </whitelist>
    </filter>
    <php>
        <env name="APP_ENV" value="testing"/>
        <env name="CACHE_DRIVER" value="array"/>
        <env name="SESSION_DRIVER" value="array"/>
        <env name="QUEUE_DRIVER" value="sync"/>
        <env name="MAIL_DRIVER" value="array"/>
        <env name="DB_CONNECTION" value="testing"/>
    </php>
</phpunit>

Other elements

It does not consider any of the test I've written: neither the basic one with assertTrue(true) nor the HTTP request test shown in the documentation (before I've said that this last one was working, but it is not). It does not execute them.

In this video guide on PHPUnit (not specifically for laravel), it does the test class by extending "PHPUnit_Framework_TestCase". I've tried and at least it considers the test functions and the assertTrue of course passes, but I cannot use this class because I want to use the TestCase with all the functionalities included for testing in Laravel.

Thanks for the help. Regards.

0 likes
4 replies
franckysolo's avatar
Level 3

Hello

try to add in your composer :

"scripts": {
        .....
        "test": "./vendor/bin/phpunit"
    },

Then run

composer test 

to execute your test

LadyC's avatar
Level 1

Thanks @frankysolo Your suggestion helped me. I had to change the path to my absolute path because I'm working on a Windows machine, but at least I see the tests running. Thanks a lot! I can go ahead!

LadyC's avatar
Level 1

I discovered why phpunit wasn't working correctly: in my System Environment Variable PATH I had written this:

C:\xampp\htdocs\todoapp\vendor\bin

instead of this:

C:\xampp\htdocs\todoapp\vendor\bin\phpunit

Maybe it will be useful for someone.

Jalagamkalyan's avatar

wat this dont you have any solution for this problem pls tell me

Please or to participate in this conversation.