How to rerun failed test cases in Jenkins build

조회 수: 10 (최근 30일)
Pooja Chauhan
Pooja Chauhan 2021년 8월 13일
답변: Pratyush 2024년 4월 16일 6:06
When we run unit test cases using 'run' in MATLAB, the failed test cases can be rerun using the hyperlink in results:
1 Passed, 1 Failed (rerun), 0 Incomplete.
Is there any similar option to run only the failed test cases in Jenkins. Or if we can store the "failedTests = suite([results.Failed]);" in results and then rerun them in Jenkins build.

답변 (1개)

Pratyush
Pratyush 2024년 4월 16일 6:06
Hi Pooja,
In Jenkins, there isn't a built-in feature like MATLAB's for rerunning only failed tests directly from the UI. However, you can achieve a similar outcome by using Jenkins plugins, scripting in Jenkins Pipeline, or employing external scripts:
  1. Some Jenkins plugins, like the Flaky Test Handler Plugin, can automatically retry failed tests a certain number of times, but they don't offer manual selection and rerun of failed tests from the UI.
  2. You can script your Jenkins Pipeline to run tests, identify failed ones, and rerun them. This involves catching exceptions from the initial test run, parsing test results to find failures, and executing a rerun command for the failed tests.
  3. Using external scripts (e.g., Python or Bash) to parse test results and identify failed tests allows more flexibility. These scripts can then rerun only the failed tests, integrating this process into Jenkins jobs either in a Pipeline step or as a build step in a freestyle project.
Each method requires some setup and configuration, such as handling the logic for identifying and rerunning failed tests and integrating test result parsing and rerun commands into your Jenkins workflow.

카테고리

Help CenterFile Exchange에서 Results, Reporting, and Test File Management에 대해 자세히 알아보기

태그

제품


릴리스

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by