Automation task in ci/cd release - retry failed tests - azure

I have a task of automation that include number of tests that running by category in ci/cd.
I'm trying to find something that I can set if certain tests or max tests fail then it will try to run them again before the task fails.
for now i have something like that in my code, any idea?
i working with VSTS (Azure - pipelines release).
thanks!

If you are using the Visual Studio Test task, the task has a built-in feature: Rerun failed tests.
According to your needs, you can specify rerunType(Do not rerun if test failures exceed specified threshold). You can specify % failures with basedOnTestFailurePercentage or # of failed tests as a threshold with basedOnTestFailureCount.

Related

How to retrieve VsTest Test Plan test case id during Azure pipeline is running and use that in automation code

Use Case:
Define a Test Plan, Test Suite and add test cases to it on ADO.
Link multiple (all) the tests on Test Plan to a single MsTest method.
Azure pipeline is setup to run the automation suite using the “Visual Studio Test” task and “Select tests using” option is set as “Test Plan”
I am searching for a solution on when Azure pipeline starts and VsTest task is running, can we get the Test case ID/Name (from ADO Test Plan) which is currently processed to run and provide that ID/Name to automation test method (as a parameter option to MsTest test). Using that test case ID, I will run few control statements in the code to perform desired tasks.
But, everything should happen runtime and the approach should be dynamic. Also, it should support parallel test execution.
Could you please share your thoughts.
TIA.
Akshay J.
Azure pipeline is setup to run the automation suite using the “Visual Studio Test” task and “Select tests using” option is set as “Test Plan”
According to your description, so Visual Studio Test task is configured like below.
In that case, you will know the id of test plan and id of test suite, so you could use Rest API: Test Suites - Get Test Cases to get all test cases in a suite including id and url, and then request this url will get fields.System.Title, that is the name of test case.
BTW, you could use API: Definitions - Get to get this release definition, in the response you will find the following VsTest task and its settings including id of test plan and id of test suite.

K6 Load Testing - Can the result be output into the Continuous Integration Pipeline?

We are using K6 for our load testing.
We want to add the load tests into our Continuous Integration pipeline (Microsoft Azure).
We were hoping that we could set thresholds that pass or fail the test. If the test fails, the Azure build pipeline would continue, however if the test fails the build pipeline would stop.
Can this be done in K6?
What you're describing is definitely possible with k6, it's actually a core use case that the tool supports. I think you'll find this Azure DevOps Pipelines guide a helpful resource:
https://k6.io/blog/integrating-load-testing-with-azure-pipelines
Reading about k6 thresholds would probably be helpful as well:
https://k6.io/docs/using-k6/thresholds
Additional links:
Github repo with example pipeline: https://github.com/k6io/example-azure-pipelines
Azure DevOps Pipelines extension: https://marketplace.visualstudio.com/items?itemName=k6.k6-load-test
It is actually the default behavior with k6! Failed thresholds cause k6 to exit with a non-zero code, which aborts the build on most CI environments.
More details: https://k6.io/blog/integrating-load-testing-with-azure-pipelines and https://k6.io/docs/using-k6/thresholds

How to combine Azure Test Pland with Pipelines?

Currently I am trying to using Azure Test Plans to manage all test cases, but I just found how to build / generate manual test cases. I also make some research about Pipeline and I just write some "hello world" test scripts and using Pipeline to automatically test the code. My question is: How could I combine TestPlans with Pipeline to make the test in pipeline recordable? Thank you so much!
this is how the pipeline looks like
this is how the test code be checked
My question is: How could I combine TestPlans with Pipeline to make
the test in pipeline recordable?
I'm a bit confused about what the recordable mean in your question. To combine TestPlan with Pipeline, you should configure the Test Plan Settings. For example, set a build pipeline(build and generates the test binaries) and a release pipeline with test-related task in your Test Plan Settings.
The normal logic is:
A test plan containing your automated tests, which you have associated with automated test methods using Visual Studio 2017, or Visual Studio 2015 or earlier.
A Team Build pipeline that generates builds containing the test binaries.
The app to test. You can deploy the app as part of the build and release workflow and also use it for on-demand testing.
For more details please check Run automated tests from test plans.

How to Run Azure Pipeline Builds Sequentially

I have created an Azure build pipeline using the 'classic editor' (i.e. not yaml). The build consists of two agent jobs:
Job 1 - Build code and deploy to test enviornment using a single agent.
Job 2 - Run tests against the test enviornment in parallel (using max 3 agents at a time).
My problem with this setup is if a build is triggered, and the tests are mid-run, if a second build is triggered, the code that is deployed to the test enviornment will be overwritten by the subsequent build, causing the test run in Job 2 of the first build to fail.
Is it possible to tell the build pipeline to only trigger builds sequentially?
I have figured out how to use Azure DevOps API to check if the latest build has completed, however Im not sure how I can use it in the pipeline. Is it possible to do something like:
1 - Invote REST API to check status of latest build.
2 - Success Criteria met (i.e. the build has completed)? If yes continue build, if not wait a minute and check again.
You have the option to control this in the Build options. Should work based on what you described.
Edit:
After looking again to your question, i noticed that you are running your tests after you deploy your app to test environment, so it means you run your tests during release, so you need to control the flow on your release and not on your buid. In order to do it, you should control on the maximum number of parallel deployments:

How to setup Gitlab-CI to fail if unit tests and Sonarqube failed?

I am setting up a Gitlab pipeline and I want it to fail if any of the stages below are true:
When there are failing unit tests (./gradlew test)
If the code doesn't pass Sonarqube Quality Gates (./gradlew --info sonarqube)
You can use Sonar GitLab Plugin for setting custom quality gates based on the number of reported issues. The plugin works asynchronously through a dedicated GitLab account and will create an additional job with the result (pass/fail).
We use it in our Android CI pipeline and it works pretty well.

Resources