我无法让我的代码覆盖率报告工作,或者更确切地说,让 DevOps 正确传递我的参数。如果我下载构建目录(在构建中压缩),则 ReportGenerator 报告可用,但不会发布。所以我知道这部分至少在起作用。:)
但是,当发布步骤运行时,它会创建新报告并使用这些报告。我的Yaml文件如下:
## Generate Reports
- task: Palmmedia.reportgenerator.reportgenerator-build-release-task.reportgenerator@4
displayName: Generate Code Coverage Reports
inputs:
reports: '**\coverage.cobertura.xml'
targetdir: 'results'
reporttypes: 'HTML;HtmlInline_AzurePipelines;Badges;Cobertura'
assemblyfilters: '-*tests*'
continueOnError: true
# Publish Code Coverage Reports
- task: PublishCodeCoverageResults@1
displayName: Publish Code Coverage Results
inputs:
disable.coverage.autogenerate: true
summaryFileLocation: $(Build.SourcesDirectory)\results\cobertura.xml
reportDirectory: $(Build.SourcesDirectory)\results
codecoverageTool: cobertura
continueOnError: true
Run Code Online (Sandbox Code Playgroud)
但是,当我在 Debug 中运行时,我得到以下输出:
##[debug]disable.coverage.autogenerate=undefined
Run Code Online (Sandbox Code Playgroud)
我尝试了以下选项来传递此参数:
disable.coverage.autogenerate: true
disable.coverage.autogenerate: 'true'
disable.coverage.autogenerate: 1
Run Code Online (Sandbox Code Playgroud)
他们都没有成功地将任何东西传递给任务。
如果没有设置此标志,任务将覆盖 ReportGenerator 生成的 HTML 报告并输出以下内容:
##[warning]Ignoring coverage report directory with Html content as we are auto-generating …Run Code Online (Sandbox Code Playgroud) 我正在使用帮助方法根据用户访问权限预过滤我的所有查询.
假设方法签名为:
public IQueryable<Client> GetAllClients()
Run Code Online (Sandbox Code Playgroud)
使用LINQ时为什么这样做:
IQueryable<Client> allItems = GetAllClients();
return (from item in allItems
where item.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase)
select item).FirstOrDefault();
Run Code Online (Sandbox Code Playgroud)
但不是这个:
return (from item in GetAllClients()
where item.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase)
select item).FirstOrDefault();
Run Code Online (Sandbox Code Playgroud)
我可以做第一个,但是离开LINQ几年之后,理解这个问题的原因会很好.
不工作我的意思是选项2给出了这个例外:
EntityFramework.SqlServer.dll中发生了'System.NotSupportedException'类型的第一次机会异常
附加信息:LINQ to Entities无法识别方法'System.Linq.IQueryable`1 [typename] GetAllClients()'方法,并且此方法无法转换为商店表达式.
客户端是存储在数据库中的数据类型.我正在为常用查询创建实体框架数据模型的方法,并且由于多租户设计具有由数据类型定义的安全访问,我想在数据访问级别进行过滤.
我期待编写单元测试来验证我的控制器,同时确保正确设置绑定属性.使用以下方法结构,如何确保仅从单元测试传递有效字段?
public ActionResult AddItem([Bind(Include = "ID, Name, Foo, Bar")] ItemViewModel itemData)
{
if (ModelState.IsValid)
{
// Save and redirect
}
// Set Error Messages
// Rebuild object drop downs, etc.
itemData.AllowedFooValues = new List<Foo>();
return View(itemData);
}
Run Code Online (Sandbox Code Playgroud)
更广泛的解释:我们的许多模型都有允许值的列表,我们不希望来回发送,所以我们在(ModelState.IsValid == false)时重建它们.为了确保这些工作,我们希望放置单元测试以断言列表已重建,但在调用方法之前没有清除列表,测试无效.
我们正在使用这个SO答案中的辅助方法来确保模型被验证,然后我们的单元测试是这样的.
public void MyTest()
{
MyController controller = new MyController();
ActionResult result = controller.AddItem();
Assert.IsNotNull(result);
ViewResult viewResult = result as ViewResult;
Assert.IsNotNull(viewResult);
ItemViewModel itemData = viewResult.Model as ItemViewModel;
Assert.IsNotNull(recipe);
// Validate model, will fail due to null name …Run Code Online (Sandbox Code Playgroud) 我在将 SSL 证书上传到 Azure 时遇到问题。我有一份来自 GoDaddy 的高级证书,该证书去年一直在 IIS 中运行。当我们迁移到 Azure 时,我将其导出到 PFX,转到 Azure 将其添加到我的 Web 应用程序,并收到以下错误消息:
Failed to update web app settings
Failed to update web app settings for [APP_NAME]: The password is incorrect, or the certificate is not valid
Run Code Online (Sandbox Code Playgroud)
我已经尝试过以下方法:
它们都有相同的结果和错误消息。有人有什么想法吗?
我正在将 Microsoft 的 Application Insights 添加到我们的主要应用程序中。虽然这进展顺利,但我还需要找出一种方法来进一步细分每个客户(SaaS 产品)的指标。
列出了站点总数的页面查看、唯一用户、访问等。我们希望能够在不显示来自客户端 B 的数据的情况下查看客户端 A 的页面浏览量。
我找到了 TrackEvent 选项,它需要构建一个复合事件,不仅包括客户端,还包括页面。我想知道是否有人知道向 TrackPageView 调用添加额外数据以减轻一些额外开销的方法,因为我们已经在跟踪页面浏览量。
提前感谢您的任何想法。