【问题标题】:How to integrate PHPunit with testrail如何将 PHPunit 与 testrail 集成
【发布时间】:2017-09-03 12:32:24
【问题描述】:

我想将我的功能测试结果与 TestRail 集成。由于测试轨道接受状态更新意味着测试是成功还是失败以与其集成。但是像 assertEqual、assertTrue 等 PHPunit 函数不返回任何值。 我们该怎么做?

public function testGetItem()
{
    $this->specify("Verify the functionality of the method ", function ($itemId, $orgId, $expectedResult) {

    $result = $this->itemRepository->getItemInfo($ItemId , $orgId);
    //$this->assertEquals($expectedResult , $result) 
    $testRail=new TestRailIntegration();
    if($this->assertEquals($expectedResult , $result)){
        $testRail->postResultsToTestRail("34530","1");
    } else{
        $testRail->postResultsToTestRail("34530","");
    }
    //34530 is testrail id
}

当测试失败时,它不会进入 else 条件。

【问题讨论】:

    标签: php phpunit codeception testrail


    【解决方案1】:

    一个简单的答案是捕获异常、发布结果并重新抛出异常。

    public function testGetItem()
    {
        $this->specify("Verify the functionality of the method ", function ($itemId, $orgId, $expectedResult) {
    
        $testRail = new TestRailIntegration();
        try {
            $result = $this->itemRepository->getItemInfo($ItemId , $orgId);
            $this->assertEquals($expectedResult, $result);
            $testRail->postResultsToTestRail("34530", "1");
        } catch (\Exception $e) {
            $testRail->postResultsToTestRail("34530", "");
            throw $e;
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-21
      • 1970-01-01
      • 2019-01-08
      • 2019-07-15
      • 2010-10-05
      相关资源
      最近更新 更多