首页> 外文期刊>MSDN Magazine >Unit Testing Asynchronous Code
【24h】

Unit Testing Asynchronous Code

机译:单元测试异步代码

获取原文
获取原文并翻译 | 示例

摘要

Unit testing is a Cornerstone of modern development. The benefits of unit testing for a project are pretty well understood: Unit testing decreases the number of bugs, reduces time to market and discourages overly coupled design. Those are all nice benefits, but there are further advantages more directly relevant to developers. When I write unit tests, I can have much greater confidence in the code. It's easier to add features or fix bugs in tested code, because the unit tests act as a safety net while the code is changing. Writing unit tests for asynchronous code brings a few unique challenges. Furthermore, the current state of async support in unit test and mocking frameworks varies and is still evolving. This article will consider MSTest, NUnit and xUnit, but the general principles apply to any unit testing framework. Most of the examples in this article will use MSTest syntax, but I'll point out any differences in behavior along the way. The code download contains examples for all three frameworks. Before diving into the specifics, I'll briefly review a conceptual model of how the async and await keywords work.
机译:单元测试是现代发展的基石。众所周知,一个项目的单元测试的好处是:单元测试减少了bug的数量,缩短了上市时间,并阻止了过度耦合的设计。这些都是不错的好处,但是还有更多与开发人员直接相关的好处。当我编写单元测试时,我可以对代码有更大的信心。在测试的代码中添加功能或修复错误更容易,因为在代码更改时,单元测试可充当安全网。为异步代码编写单元测试带来了一些独特的挑战。此外,单元测试和模拟框架中异步支持的当前状态各不相同,并且仍在不断发展。本文将考虑MSTest,NUnit和xUnit,但是一般原则适用于任何单元测试框架。本文中的大多数示例都将使用MSTest语法,但我会指出整个过程中的行为差异。该代码下载包含所有三个框架的示例。在深入探讨细节之前,我将简要回顾一下async和await关键字如何工作的概念模型。

著录项

  • 来源
    《MSDN Magazine》 |2014年第11期|16-1820|共4页
  • 作者

    Stephen Cleary;

  • 作者单位
  • 收录信息
  • 原文格式 PDF
  • 正文语种 eng
  • 中图分类
  • 关键词

相似文献

  • 外文文献
  • 中文文献
  • 专利
获取原文

客服邮箱:kefu@zhangqiaokeyan.com

京公网安备:11010802029741号 ICP备案号:京ICP备15016152号-6 六维联合信息科技 (北京) 有限公司©版权所有
  • 客服微信

  • 服务号