简体   繁体   English

Laravel:PHPUnit测试不会触发

[英]Laravel: PHPUnit tests not triggering

I want to test one of my classes, but it looks like the Phpunit is not working. 我想测试我的一门课,但看来Phpunit无法正常工作。

This is the test below: 这是下面的测试:

<?php

use NERO\Datagrids\Datagrid;

class DatagridTest extends TestCase
{

    public function __construct()
    {
        $this->datagrid = new Datagrid;
    }

    public function testStopMethod()
    {
        $response = $this->datagrid->stop();
        $this->assertEquals($response, 'Stop');
    }

}

And the class itself: 和类本身:

<?php

namespace NERO\Datagrids;

class Datagrid {

    public function stop()
    {
        return 'Stop';
    }

}

I don't event get any reponse from the command line. 我不会从命令行获得任何响应。 I do the following and nothing happens.. 我执行以下操作,但没有任何反应。

intelis:laravel me$ clear
intelis:laravel me$ vendor/bin/phpunit 
intelis:laravel me$

Thanks for your help! 谢谢你的帮助!

Please not use __construct , instead: 请不要使用__construct ,而是:

<?php

use NERO\Datagrids\Datagrid;

class DatagridTest extends TestCase
{
    protected $datagrid;

    public function setUp()
    {
        $this->datagrid = new Datagrid;
    }

    public function testStopMethod()
    {
        $response = $this->datagrid->stop();
        $this->assertEquals($response, 'Stop');
    }

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM