How to run Api integration tests
Currently we are able to run tests on following environment types: vm, k8s, helm
Please, refer to this article if you don't have VM environment - /wiki/spaces/RedboxHome/pages/2562764310, (skip if you already have an environment)
Ways how to run tests
- From Azure Devops
- From Visual Studio using Test Explorer
Test framework structure
On the top we have solution which contains multiple projects, every project contains at least one test class and every test class contains at least one test method (test scenario)
Below is the example of how it looks in code
We can run following sets of tests:
- All tests in the solution
- Tests for specific project
- Test class (feature)
- Test method (scenario)
- Smoke set of tests - all tests in the ApiAutomation solution marked with SmokeTest attribute
Running tests from Azure Devops
There 5 builds depending on suite of tests:
Single test case - https://redboxdev.visualstudio.com/Nubis/_build?definitionId=381
Single test class - https://redboxdev.visualstudio.com/Nubis/_build?definitionId=372
Project - https://redboxdev.visualstudio.com/Nubis/_build?definitionId=258
Smoke tests - https://redboxdev.visualstudio.com/Nubis/_build?definitionId=313
All tests - https://redboxdev.visualstudio.com/Nubis/_build?definitionId=187
To run all tests trigger build Api tests regression
- Open build page
- Click button "Run pipeline"
- Select branch from the dropdown list:
- Open "Variables" tab and provide "environmentTag" and "envKind" values:
EnvironmentTag is a part of virtual machine environment URL:
vm: http://dev-vm-TAG.westeurope.cloudapp.azure.com
helm: https://TAG.dev.redboxdev.com
k8s:List of existing kubernetes environments is described on this page - Environments
Based on Environments page there's environments.json file in ApiAutomation solution
environments.json file contains mapping between IP address and environmentTag
Environment kind (envKind) is one of following environment types: vm, k8s, helm - Click "Run" button
To run tests for specific project trigger build Api test run for single project
- Open build page
- Click button "Run pipeline"
- Select branch, environmentTag, envKind and projectName
projectName value should be equal to one of project names in the ApiAutomation solution, e.g. AuditApiTest, AnnotateCallTest..... - Click button "Run"
To run tests for specific test class (feature) trigger build Api tests single feature
- Open build page
- Click "Run pipeline" button
- Select branch, environmentTag, envKind and test class name (feature)
feature parameter should be equal to test class name - Click "Run" button
Running smoke tests - Api tests run smoke test suite
- Open build page
- Click "Run pipeline" button
- Select branch branch, environmentTag, envKind
- Click "Run" button
Running tests from Visual Studio Test Explorer
Steps to run tests:
- Clone AutomationTests repository
- Switch to the branch you're interested in (you might have to do a fetch through [Team Explorer > Synchronisation > Fetch])
- Go to AutomationTests\ApiAutomation
- Open ApiAutomation solution in Visual Studio
- Configure RBR package source in the Visual Studio if it's not configured, please refer to the article "How to add package source"
- Build the solution (ensure that there are no errors else reach out to automation engineers)
- In the ApiTestCommon project find "appsettings.common.json" file
- In the "appsettings.common.json" file replace placeholder "%envHost%" to the target environment tag, e.g: "fenrir3" or "fenrir4
- In the "appsettings.common.json" file replace ip "172.16.250.14" to the ip of the target environment
- In the "appsetting.k8s.json" file set "environmentTag" to the target environment tag, e.g: "fenrir3" or "fenrir4
- In the "appsetting.environment.json" file add the ip of the target environment
- Re-build the solution
- Open Test Explorer
- In Test Explorer right lick on project/class/method to run specific tests or click "Run All" link to run all tests
In order to run Smoke tests:
- Open Test Explorer
- Click on "Open playlist file"
- Select "smoke_tests.playlist" file from ApiAutomation folder in the AutomationTests repository
- There're only smoke tests will be displayed in the Test Explorer
Sign Off
- Vikash Mahabir (Unlicensed)
- Jayasri (Unlicensed)
- Baz Chougule (Unlicensed)
- Denis Shevchenko (Deactivated)
- Abdullah Arshad (Unlicensed)
- Kirill Martyshchenko (Unlicensed)