메뉴 건너뛰기

게임 커뮤니티 4브론즈

IT 해외 뉴스

本篇翻译于Jakub Jareš的Supercharge your testing experience with MSTest.Analyzers – .NET Blog (microsoft.com)  MSTest 附带一组分析器,用于检查您的测试代码并指出常见的错误和陷阱。这些错误可能很微妙,并导致测试框架完全忽略您的测试。  我们从 3.2.0 版本就开始提供这些分析器了,但在最新的 3.5.1 版本中,我们添加了一些我们认为您不应错过的分析器。  遗漏的测试  一个常见问题是当您忘记在类上添加 [TestClass] 时。MSTest 将无法知道类中有测试,也不会运行它们:  public class MyTests { [TestMethod] public async Task TestMethod1() { Assert.Fail(); } } 如果没有 MSTest.Analyzers,此代码在构建时不会出现警告或信息提示。运行测试时也不会出现测试失败的情况。由于类上没有 [TestClass] 属性,MSTest 会出于性能原因跳过整个类,并且您的测试将永远不会被找到。  但是使用分析器时您会在构建过程中收到一条信息提示:  我们建议将此信息提示升级为警告,甚至是构建错误。可以通过在 .editorconfig 文件中添加以下这行代码来实现  [*.cs] # MSTEST0030: Type containing '[TestMethod]' should be marked with '[TestClass]' dotnet_diagnostic.MSTEST0030.severity = warning 为什么默认情况下这不是警告?  您可能会问为什么 MSTEST0030 默认是一条信息提示而不是默认的警告。原因是我们不能在 MSTest v3 中引入重大变更,而上述代码是一个常见的模式,用于从基类重用测试。  public class MyTestsBase { [TestMethod] public async Task CommonTestMethod() { } } [TestClass] public class MyTests : MyTestsBase { [TestMethod] public async Task TestMethod1() { Assert.Fail();


원문출처 : https://devblogs.microsoft.com/dotnet-ch/%E4%BD%BF%E7%94%A8-mstest-analyzers-%E5%A2%9E%E5%BC%BA%E6%82%A8%E7%9A%84%E6%B5%8B%E8%AF%95%E4%BD%93%E9%AA%8C
번호 제목 글쓴이 날짜 조회 수
공지 자동수집 대상 사이트 KanoT 2023.02.14 2148
2508 [DevBlogs] Enhance Your Cloud Development Skills at ‘Azure Developers – .NET Aspire Day 2024’ 뉴스봇 2024.09.04 157
2507 [DevBlogs] Load optimization in Azure Fluid Relay using Managed Prometheus 뉴스봇 2024.09.04 1482
2506 [Godot] About Official Console Ports 뉴스봇 2024.09.04 102
2505 [DevBlogs] Enhancing your Visual Studio authentication experience 뉴스봇 2024.09.03 1300
2504 [Stack Overflow] At scale, anything that could fail definitely will 뉴스봇 2024.09.03 1179
2503 [Godot] Meeting the community at gamescom 2024 뉴스봇 2024.09.03 100
2502 [DevBlogs] Announcing the Proxy 3 Library for Dynamic Polymorphism 뉴스봇 2024.09.03 118
2501 [DevBlogs] The Co­Initialize­Security function demands an absolute security descriptor 뉴스봇 2024.09.02 99
2500 [DevBlogs] Introducing Azure AI Inference Connector for Azure AI Studio Models 뉴스봇 2024.08.31 1071
2499 [DevBlogs] Microsoft Graph APIs for Teams webinar registration now generally available 뉴스봇 2024.08.30 1404
2498 [DevBlogs] Announcing ASP.NET Core OData 9 Official Release 뉴스봇 2024.08.30 132
» [DevBlogs] 使用 MSTest.Analyzers 增强您的测试体验 뉴스봇 2024.08.30 112
2496 [Stack Overflow] Mobile Observability: monitoring performance through cracked screens, old batteries, and crappy Wi-Fi 뉴스봇 2024.08.30 173
2495 [DevBlogs] We are deprecating earlier versions of Visual Studio for Dynamics 365 for Finance and Operations development 뉴스봇 2024.08.30 109
2494 [DevBlogs] Announcing .NET Aspire 8.2 – Goodbye Components, Hello Integrations! 뉴스봇 2024.08.30 130
2493 [DevBlogs] Vector Support EAP extended to Azure SQL MI 뉴스봇 2024.08.30 136
2492 [DevBlogs] New GitHub Copilot features in Visual Studio 2022 17.11 뉴스봇 2024.08.30 205
2491 [DevBlogs] How is the Windows.Foundation.Uri.Domain property different from Host? 뉴스봇 2024.08.30 109
2490 [DevBlogs] Dev Proxy v0.20 with improved simulating API errors and a new API for building integrations 뉴스봇 2024.08.29 125
2489 [DevBlogs] Microsoft 365 Certification control spotlight: Patch management 뉴스봇 2024.08.29 122
위로