第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

phpunit 運行名稱中沒有“test”的類

phpunit 運行名稱中沒有“test”的類

PHP
30秒到達(dá)戰(zhàn)場 2022-01-24 10:45:29
如何表明phpunit 該類是測試類?/** @test */注釋似乎僅適用test于名稱中未附加字符串的方法那么如何在不將test字符串附加到其名稱的情況下運行測試類呢?這是課程<?phpnamespace Tests\Feature;use Tests\TestCase;/** @test */class RepoPost extends TestCase{    /** @test */    public function postSave()    {        $this->assertTrue(true);    }    /** @test */    public function anotherOne()    {        $this->assertTrue(true);    }}跑步vendor/bin/phpunit --filter RepoPost輸出未執(zhí)行任何測試!更新這是我的phpunit.xml配置<?xml version="1.0" encoding="UTF-8"?><phpunit backupGlobals="false"         backupStaticAttributes="false"         bootstrap="tests/bootstrap.php"         colors="true"         processIsolation="false"         stopOnFailure="false">    <testsuites>        <testsuite name="Feature">            <directory>./tests/Feature</directory>        </testsuite>    </testsuites>    <php>        <server name="APP_ENV" value="testing"/>    </php></phpunit>正如@Alister指出的那樣,雖然可以通過完整路徑運行該類vendor/bin/phpunit tests/Feature/RepoPost.php對每個課程一遍又一遍地執(zhí)行此操作并不方便,尤其是作為 CI 過程的一部分理想情況下,該課程將在完整的測試套件中運行vendor/bin/phpunit
查看完整描述

3 回答

?
汪汪一只貓

TA貢獻(xiàn)1898條經(jīng)驗 獲得超8個贊

在您的 phpunit.xml 中,將 suffix 屬性添加到標(biāo)簽中。該示例將運行所有.php文件,如果您在那里沒有任何 TestCase 類/文件,這可能會變得有風(fēng)險,這就是為什么它的約定使用Test.


<testsuite name="Feature">

    <directory suffix=".php">./tests/Feature</directory>

</testsuite>

希望這可以幫助!


查看完整回答
反對 回復(fù) 2022-01-24
?
慕沐林林

TA貢獻(xiàn)2016條經(jīng)驗 獲得超9個贊

它不讀取類級別的/** @test */注釋,但默認(rèn)的 phpunit.xml 文件也具有使用文件名后綴定義的測試套件:


 <testsuites>

     <testsuite name="default">

         <directory suffix="Test.php">tests</directory>

     </testsuite>

 </testsuites>

如果您在特定文件上運行 phpunit:vendor/bin/phpunit tests/RepoPost.php它會運行測試,即使文件名與后綴不匹配。


查看完整回答
反對 回復(fù) 2022-01-24
?
慕容708150

TA貢獻(xiàn)1831條經(jīng)驗 獲得超4個贊

您可以使用后綴:

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

然后你應(yīng)該將你的文件重命名為 RepoPostTest.php


查看完整回答
反對 回復(fù) 2022-01-24
  • 3 回答
  • 0 關(guān)注
  • 148 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號