簡體   English   中英

Codeception:如何對消息進行顏色測試

[英]Codeception:how to color test message

我想給消息加色。 如果測試通過,則輸出消息顏色為綠色,否則為紅色。

 $I = $this->apiTester;  //$this->apiTester is instance of ApiTester.php Class

    if ($outputData['success'] == true) {        //$outputdata is json array
        $I->comment("see test status:Passed.");  //I want its color green
    } else {
        $I->comment("see test status:Failed.");  //I want its color red
    }
$I->comment("\e[0m\e[35msee test status:Failed.\e[0m");

ANSI轉義碼

一個好的解決辦法做,這是使用創造Codeception你_support /助手目錄中的新Color.php Helper類這個類和修改命名空間:命名空間的幫手;

然后,您可以在測試中像這樣使用它:

$I->comment(\Helper\Color::set("see test status:Failed.", "red");

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM