doulao1934 2017-04-08 03:06
浏览 40

如何将PHPunit与testrail集成

I want to integrate my functional test result with TestRail . Since test rail accept status update means whether the test is success or fail for integrating with it . But PHPunit functions like assertEqual, assertTrue, etc do not return any values. How can we do this?

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
}

when a test fails it does not go to the else condition.

  • 写回答

1条回答 默认 最新

  • douzong5057 2017-04-10 19:18
    关注

    A straightforward answer is to catch exception, post result and rethrow exception.

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

报告相同问题?

悬赏问题

  • ¥15 echarts动画效果失效的问题。官网下载的例子。
  • ¥60 许可证msc licensing软件报错显示已有相同版本软件,但是下一步显示无法读取日志目录。
  • ¥15 Attention is all you need 的代码运行
  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
  • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事:
  • ¥15 前置放大电路与功率放大电路相连放大倍数出现问题
  • ¥30 关于<main>标签页面跳转的问题
  • ¥80 部署运行web自动化项目
  • ¥15 腾讯云如何建立同一个项目中物模型之间的联系
  • ¥30 VMware 云桌面水印如何添加