2

Is there a way in VSTS Azure for DevOps to implement unit test checking mechanism on pull request.

The condition is to only allow commits that change something in the unittest folder for example.

Notes:

  • we are using GoCD as a CI/CD system so it's external building.

  • Git is internal hosted within VSTS.

1
  • You can create a build with the unit tests and tun this build on the PR – Shayki Abramczyk Jan 9 '19 at 12:55
1

If you have the option, Github offers Actions which allow you to run workflows on different events - one of them being push.

If Github is not an option, I would recommend creating a build where deployment of the artifacts only happens if the build is done on master.

On your feature branches, on checkin, a build will happen which will pull the latest code, compile, and then run unit tests, security scanning, and code coverage (if applicable). Since this is a feature branch, the build ends there.

If it is on master, it then performs the steps to package/deploy the artifacts.

In Branches > Master > Branch Policies (in the ellipses menu), add a Build Validation.

I recommend marking it required.

If you aren't worried about merge conflicts causing a rebuild, you can make it expire immediately upon master changing (requiring a rebuild, which will fail on merge conflicts).

If you are a large team where you might frequently step on one another, you can make it never expire and leave it up to the developer to fix manually before they are able to merge.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.