How to rerun failed test cases in Jenkins build

10 visualizzazioni (ultimi 30 giorni)
Pooja Chauhan
Pooja Chauhan il 13 Ago 2021
Risposto: Pratyush il 16 Apr 2024 alle 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.

Risposte (1)

Pratyush
Pratyush il 16 Apr 2024 alle 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.

Categorie

Scopri di più su Results, Reporting, and Test File Management in Help Center e File Exchange

Prodotti


Release

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by