尽管断言失败,但Gitlab Job还是成功的

发布于 2025-02-07 07:24:57 字数 2736 浏览 1 评论 0原文

我正在使用Gitlab中使用Maven图像进行肥皂断言。即使断言失败了,在吉特拉布(Gitlab)中构建仍然成功。我尝试使用MVN集成测试-FF和-FAE,但没有运气。还使用允许_Failure:false。这也无效。如果断言失败,请告知如何使GitLab管道工作失败。

这是我的yml文件

T001-0011:
  extends: .ETE -stage
  image: adoptopenjdk/maven-openjdk11
  variables:
   MAVEN_CLI_OPTS: "--fail-fast"
  script:
  - 'mvn -f ./TV001/pom.xml $MAVEN_CLI_OPTS integration-test'
  allow_failure: false
     
  when: always

,这是gitlab日志

   1 error
    09:53:48,937 ERROR [SoapUITestCaseRunner] JDBC_Request failed, exporting to [/builds/gitlab/data/test-team-automation-scripts/./SV321/Warnings/target/surefire-reports/TestSuite_1-AC1-JDBC_Request-0-FAILED.txt]
    09:53:48,938 INFO  [SoapUITestCaseRunner] Finished running SoapUI testcase [AC1], time taken: 904ms, status: FAILED
    09:53:48,953 INFO  [SoapUITestCaseRunner] Running SoapUI testcase [AC2]
    09:53:48,963 INFO  [SoapUITestCaseRunner] running step [IDN220001-Request2]
    09:53:48,966 DEBUG [HttpClientSupport$SoapUIHttpClient] Stale connection check
    09:53:48,968 DEBUG [HttpClientSupport$SoapUIHttpClient] Attempt 1 to execute request
    09:53:48,968 DEBUG [SoapUIMultiThreadedHttpConnectionManager$SoapUIDefaultClientConnection] Sending request: GET /apikey/v1/warnings/waning/IDN22000 HTTP/1.1
    09:53:48,974 DEBUG [SoapUIMultiThreadedHttpConnectionManager$SoapUIDefaultClientConnection] Receiving response: HTTP/1.1 404 Not Found
    09:53:48,975 DEBUG [HttpClientSupport$SoapUIHttpClient] Connection can be kept alive indefinitely
    09:53:49,018 INFO  [log] HTTP status code: 404
    09:53:49,019 INFO  [SoapUITestCaseRunner] Assertion [Valid HTTP Status Codes] has status UNKNOWN
    09:53:49,019 INFO  [SoapUITestCaseRunner] Assertion [Script Assertion] has status VALID
    09:53:49,019 INFO  [SoapUITestCaseRunner] Finished running SoapUI testcase [AC2], time taken: 8ms, status: FINISHED
    09:53:49,021 INFO  [SoapUITestCaseRunner] Project [DPD-3396] finished with status [FAILED] in 2591ms
    SoapUI 5.3.0 TestCaseRunner Summary
    -----------------------------
    Time Taken: 2599ms
    Total TestSuites: 1
    Total TestCases: 2 (1 failed)
    Total TestSteps: 3
    Total Request Assertions: 5
    Total Failed Assertions: 1
    Total Exported Results: 3

[WARNING] JAR will be empty - no content was marked for inclusion!
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  03:03 min
[INFO] Finished at: 2022-06-15T09:53:54+10:00
[INFO] ------------------------------------------------------------------------
Cleaning up file based variables
00:01
Job succeeded

I am running SoapUI assertions using maven image in gitlab. Even though the assertion fails the build is successful in gitlab. I have tried using mvn integration-tests -ff and as well as -fae but no luck. Also used allow_failure: false. This did not work either. Please advise as to how to fail the gitlab pipeline job if there is a failure in assertions.

Here is my yml file

T001-0011:
  extends: .ETE -stage
  image: adoptopenjdk/maven-openjdk11
  variables:
   MAVEN_CLI_OPTS: "--fail-fast"
  script:
  - 'mvn -f ./TV001/pom.xml $MAVEN_CLI_OPTS integration-test'
  allow_failure: false
     
  when: always

Here is the gitlab log

   1 error
    09:53:48,937 ERROR [SoapUITestCaseRunner] JDBC_Request failed, exporting to [/builds/gitlab/data/test-team-automation-scripts/./SV321/Warnings/target/surefire-reports/TestSuite_1-AC1-JDBC_Request-0-FAILED.txt]
    09:53:48,938 INFO  [SoapUITestCaseRunner] Finished running SoapUI testcase [AC1], time taken: 904ms, status: FAILED
    09:53:48,953 INFO  [SoapUITestCaseRunner] Running SoapUI testcase [AC2]
    09:53:48,963 INFO  [SoapUITestCaseRunner] running step [IDN220001-Request2]
    09:53:48,966 DEBUG [HttpClientSupport$SoapUIHttpClient] Stale connection check
    09:53:48,968 DEBUG [HttpClientSupport$SoapUIHttpClient] Attempt 1 to execute request
    09:53:48,968 DEBUG [SoapUIMultiThreadedHttpConnectionManager$SoapUIDefaultClientConnection] Sending request: GET /apikey/v1/warnings/waning/IDN22000 HTTP/1.1
    09:53:48,974 DEBUG [SoapUIMultiThreadedHttpConnectionManager$SoapUIDefaultClientConnection] Receiving response: HTTP/1.1 404 Not Found
    09:53:48,975 DEBUG [HttpClientSupport$SoapUIHttpClient] Connection can be kept alive indefinitely
    09:53:49,018 INFO  [log] HTTP status code: 404
    09:53:49,019 INFO  [SoapUITestCaseRunner] Assertion [Valid HTTP Status Codes] has status UNKNOWN
    09:53:49,019 INFO  [SoapUITestCaseRunner] Assertion [Script Assertion] has status VALID
    09:53:49,019 INFO  [SoapUITestCaseRunner] Finished running SoapUI testcase [AC2], time taken: 8ms, status: FINISHED
    09:53:49,021 INFO  [SoapUITestCaseRunner] Project [DPD-3396] finished with status [FAILED] in 2591ms
    SoapUI 5.3.0 TestCaseRunner Summary
    -----------------------------
    Time Taken: 2599ms
    Total TestSuites: 1
    Total TestCases: 2 (1 failed)
    Total TestSteps: 3
    Total Request Assertions: 5
    Total Failed Assertions: 1
    Total Exported Results: 3

[WARNING] JAR will be empty - no content was marked for inclusion!
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  03:03 min
[INFO] Finished at: 2022-06-15T09:53:54+10:00
[INFO] ------------------------------------------------------------------------
Cleaning up file based variables
00:01
Job succeeded

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一枫情书 2025-02-14 07:24:57

MVN测试失败,但命令本身返回的退出代码可能为零。

这就是说,我设法进行了测试。
但是对于您来说,这无济于事,因为您想检查测试的结果。

GitLab为了失败,请检查所用命令的退出代码。您可以强迫MVN返回错误的出口代码,当测试失败时,

您可以添加以下标志

-Dmaven.test.failure.ignore=false

The mvn tests fail but the exit code that the command itself returns, probably is zero.

It is saying, I managed to run the tests.
But for you this doesn't help since you want to check the result of the tests.

Gitlab in order to fail a job checks the exit code of the commands used. You could force mvn to return an erroneous exit code when the tests fail

You could add the following flag

-Dmaven.test.failure.ignore=false
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文