最近的一篇文章,我们写了关于在合并请求中运行Quish测试 GitLab。在本文中,我们提出了一个解决方案来运行每次提交的Squish测试。

概述

We invoke the squishrunner command to execute tests and generate JUnit and web reports. Additionally, squishrunner is called with a --exitCodeOnFail switch so it returns a custom exit code (nonzero) if any of the test cases have failed, and zero otherwise. Therefore, GitLab is able to set the job status accordingly.

runner设置

第一步是配置Gitlab Runner。我们将配置以下环境变量:

  • squ_dir.–挤压安装目录
  • squish_licensekey_dir.–挤压许可位置
  • squish_server_port.–SquishServer进程启动的港口
  • 展示–显示用于显示应用GUI的显示。我们使用VNC服务器提供无头显示。

作业配置

The next step is to define a pipeline in the file .gitlab-ci.yml. Pipelines are defined by specifying jobs that run in stages. In our example, we define a job named “squish-tests1”在测试阶段运行。

DEMISH-TESTS1: stage: test script: - echo DISPLAY=$DISPLAY - echo "开始 ing VNC Server" - vncserver :$DISPLAY_NO - echo $SQUISH_DIR - echo "开始 ing squishserver on port=$SQUISH_SERVER_PORT..." - $SQUISH_DIR/bin/squishserver --port $SQUISH_SERVER_PORT 1>server.log 2>&1 & - sleep 5 - echo "登记 AUT..." - $SQUISH_DIR/bin/squishserver --port $SQUISH_SERVER_PORT --config addAUT addressbook $SQUISH_DIR/examples/qt/addressbook - echo "开始 ing tests..." - $SQUISH_DIR/bin/squishrunner --port $SQUISH_SERVER_PORT --testsuite /home/tomasz/suites/suite_PageObjects --exitCodeOnFail 13 --reportgen junit,junit_report.xml --reportgen html,web_report after_script: - echo "停止ping squishserver..." - $SQUISH_DIR/bin/squishserver --stop --port $SQUISH_SERVER_PORT & - echo "停止ping VNC Server..." - vncserver -kill :$DISPLAY_NO - sleep 5 artifacts: when: always reports: junit: junit_report.xml paths: - server.log - junit_report.xml - web_report/
Code language: PHP (php)

该作业执行以下操作:

  1. 开始  squishserver 并将其stdout和stderr输出重定向到a server.log file
  2. 注册测试下的应用程序(AUT)
  3. 称呼 squishrunner to run the test suite and generate a JUnit report and HTML report and set --exitCodeOnFail 13 setting
  4. 停止 squishserver
  5. Collect artifacts. We use the setting when: always, so artifacts are collected regardless of job status (by default GitLab only collects artifacts on successful job executions, which is not good in our case, as we need an HTML report to analyze the cause of failures).

例子

在提交对AUT的更改时,将启动管道脚本中定义的作业。构建应用程序(我们的管道示例中未涵盖)后,执行测试阶段。作为本阶段的一部分,使用鳞茎的GUI测试仪执行GUI测试。下面的屏幕截图显示了从测试执行中输出的控制台输出。

After test execution, artifacts, including the HTML report, are uploaded. To analyze detailed results in the HTML report, you need to select Download in the Job Artifacts view and open web_report/index.html in a web browser.

1 Comment

你好,

我试图用quishr​​unner使用gitlab,我在不使用的情况下得到一个问题“13” in the “–exitCodeOnFail 13”.
我的管道被困在一起“1”,强制性是什么“13” ? and why it’没有在您的文档中解释? (//doc.fzlmzk.icu/squish/latest/rg-cmdline.html#rg-squishrunner-cli-playback–exitCodeOnFail)

非常感谢。

发表评论

您的电子邮件地址不会被公开。 必需的地方已做标记 *

复制链接