簡體   English   中英

Laravel:PHPUnit測試不會觸發

[英]Laravel: PHPUnit tests not triggering

我想測試我的一門課,但看來Phpunit無法正常工作。

這是下面的測試:

<?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');
    }

}

和類本身:

<?php

namespace NERO\Datagrids;

class Datagrid {

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

}

我不會從命令行獲得任何響應。 我執行以下操作,但沒有任何反應。

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

謝謝你的幫助!

請不要使用__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