c# – 在同一个组件中混合单元测试和集成测试
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了c# – 在同一个组件中混合单元测试和集成测试,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2663字,纯文字阅读大概需要4分钟。
内容图文
我的队友现在已经理解了(!?)集成测试和单元测试之间的区别.现在,在我们的项目中,为每个组件建立了一个测试组件.
目前,集成测试没有像SpecFlow或Cucumber这样的特殊框架.它们是普通(和长)NUnit测试方法,其中来自不同组件的几个类一起测试.
现在的计划是使用“单元测试”和“集成测试”按属性(C#)对测试进行分类,以便NUnit可以在必要时过滤相应的测试.
是否适合将集成测试和单元测试混合在同一个组件中,还是应该总是在不同的组件中进行分离?
解决方法:
从技术上讲,这可能有用,但你为什么要这样做呢?
单元测试是测试一个“单元”,它可能是一个函数或测试组件所属的组件内的任何其他一小段代码(每个组件的一个测试组件),一个集成测试是关于测试一些逻辑通常在多个程序集中实现,因此为集成测试提供额外的程序集并将它们与单元测试分开,实际上是我眼中更好的配置.
从一些相关的article中读取这个:
Integration Testing While unit tests verify the functionality of a
piece of code in isolation, integration tests verify the functionality
of a piece of code against a target system or platform. Just like unit
tests, integration tests are automated procedures that run within a
testing framework. Although comprehensive unit testing verifies that
your code behaves as expected in isolation, you still need to ensure
that your code behaves as expected in its target environment, and that
the external systems on which your code depends behave as anticipated.
That is where integration testing comes in. Unlike a unit test, an
integration test executes all code in the call path for each method
under test—regardless of whether that code is within the class you are
testing or is part of an external API. Because of this, it takes much
longer to set up the test conditions for an integration test. For
example, you may need to create users and groups or add lists and list
items. Integration tests also take considerably longer to run.
However, unlike unit tests, integration tests do not rely on
assumptions about the behavior of external systems and services. As a
result, integration tests may detect bugs that are missed by unit
tests. Developers often use integration tests to verify that external
dependencies, such as Web services, behave as expected, or to test
code with a heavy reliance on external dependencies that cannot be
factored out. Testers often also develop and use integration tests for
more diverse scenarios, such as security testing and stress testing.
In many cases, organizations do not distinguish between integration
and unit testing, because both types of tests are typically driven by
unit testing frameworks such as nUnit, xUnit, and Visual Studio Unit
Test. Typically, organizations that use agile development practices
make this distinction, because the two types of tests have different
purposes within the agile process.
内容总结
以上是互联网集市为您收集整理的c# – 在同一个组件中混合单元测试和集成测试全部内容,希望文章能够帮你解决c# – 在同一个组件中混合单元测试和集成测试所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。