How to rerun failed test cases in Jenkins build

23 visualizaciones (últimos 30 días)
Pooja Chauhan
Pooja Chauhan el 13 de Ag. de 2021
Respondida: Pratyush el 16 de Abr. de 2024
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.

Respuestas (1)

Pratyush
Pratyush el 16 de Abr. de 2024
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.

Categorías

Más información sobre Testing Frameworks en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by