强制开发人员在Azure Devops中提高PR之前运行单元测试项目 [英] Force developer to run unit test project before PR is Raised in Azure Devops

查看:262
本文介绍了强制开发人员在Azure Devops中提高PR之前运行单元测试项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写.Net 4.8代码,并在单个程序集dll中进行MSTest测试.使用Azure Devops git作为存储库.仅当所有单元测试都通过时,分支中的代码才应签入.是否有可能?如果需要的话,我也可以使用一些脚本(例如powershell等)来帮助我启用此功能.

I am writing .Net 4.8 code and have MSTest tests in a single assembly dll. Using Azure Devops git as repository. The code in the branch should check-in only if all unit test PASS. Is it possible? I am also ok, if required, to use some script like powershell etc.. to help me enable this.

推荐答案

您可以使用分支策略来强制特定的构建运行并在PR可以合并之前成功执行.您必须创建一个运行这些测试的构建,并配置分支策略以运行该构建(请查看下面的链接以了解如何确切地做到这一点).

you can use branch policies to force a specific build to run and succeed before PR can be merged. You have to create a build that runs those tests and configure branch policies to run that build (consult the link below to figure out how to do that exactly).

简而言之:转到分支,单击分支附近的3个点,然后选择分支策略".然后配置构建验证.

in short: go to branches, click 3 dots near branch and choose "branch policies". then configure build validation.

https://docs.microsoft.com/zh-cn/azure/devops/repos/git/branch-policies?view=azure-devops#build-validation

这篇关于强制开发人员在Azure Devops中提高PR之前运行单元测试项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆