![]() Install-Module -Name Pester -Force -SkipPublisherCheck This wrapper will be invoked from the release pipeline directly. The next script we need is a wrapper around the above script called Invoke-TestsAfterDeployment.ps1. \Invoke-Tests.ps1 -Api " You should get a reponse like below: Describing Example API (' Tests If you want to run the tests locally you’ll need to run the CoolApi on a console like this It then proceeds to do a test on the POST and the GET verbs on that Api using Pester. The above script accepts a parameter -Api. Windows 10 will automatically detect you’re using Pester from the keywords Describe, It, and Should. $result = Invoke-WebRequest -Uri "$Api/api/Cool" ` The first one is the actual test script that interrogates our application called Invoke-Tests.ps1. ![]() We need two PowerShell scripts to setup before integrating them into our release pipeline. I’ve setup my CoolApi to deploy into an Azure Web App by using the task from the marketplace called Azure App Service Deploy. Next step, setup a release pipeline on Azure DevOps. You can use your application or my CoolApi from the repository above, it already contains a build.yaml file so you can use this to quickly setup your build definition. To start, setup a build pipeline on Azure DevOps. Feel free to skip this step and go straight to the next section if you already have a deployed application. In this step we’ll setup the build and release pipeline for the CoolApi without tests. You can choose to fork or copy and paste into a private repository and follow on. NET project called CoolApi.csproj with two PowerShell Scripts Invoke-Tests.ps1 and Invoke-TestsAfterDeployment.ps1. In this post, I will run through how I do this with release pipelines on Azure DevOps using Pester as a testing framework. Post deployment tests provide additional confidence that unit tests or self-contained integration tests will not, as the tests themselves are interrogating a live instance of your application as a black box, rather than mocking aspects of your application like unit tests as a white box. Post Deployment Tests on Azure DevOps using Pester
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |