如何将PHPunit与testrail集成

如何将PHPunit与testrail集成,php,phpunit,codeception,testrail,Php,Phpunit,Codeception,Testrail,我想将我的功能测试结果与TestRail集成。因为test rail接受状态更新意味着与之集成的测试是成功还是失败。但是像assertEqual、assertTrue等PHPunit函数不返回任何值。 我们怎样才能做到这一点 public function testGetItem() { $this->specify("Verify the functionality of the method ", function ($itemId, $orgId, $expectedResu

我想将我的功能测试结果与TestRail集成。因为test rail接受状态更新意味着与之集成的测试是成功还是失败。但是像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状态。

一个简单的答案是捕获异常、发布结果和重新显示异常

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;
    }
}