如何将单元测试与集成测试分开?

时间:2022-09-25 11:49:58

I am new to testing and mocking. I'm trying to test a business logic class which performs calculations, calls into the DAL and updates the database, and manages transactions. I'm using mocks to do unit testing, but how does full integration testing fit into all of this. Do I basically have the exact same tests, but use the real DAL or do I do something completely different?

我是测试和嘲笑的新手。我正在尝试测试一个业务逻辑类,它执行计算,调用DAL并更新数据库,并管理事务。我正在使用模拟进行单元测试,但完全集成测试如何适用于所有这些。我基本上有完全相同的测试,但使用真正的DAL还是我做了一些完全不同的事情?

2 个解决方案

#1


3  

Pretty much. The important thing to know is that unit testing (in TDD) is not much about testing as it's about design. You create unit test to incorporate design decisions of every single component of code in an automated validation system; so that each part of your system conforms to its design. This way, you can rely on each component is not relying on unspecified features of other components.

差不多。重要的是要知道单元测试(在TDD中)并不是关于测试,而是关于设计。您可以创建单元测试,以在自动验证系统中合并每个代码组件的设计决策;以便系统的每个部分都符合其设计。这样,您可以依赖每个组件而不依赖于其他组件的未指定功能。

#2


2  

You can pretty much think of it the way that you are thinking of it. You could add and additional step if you wanted to however and do a process test. In testing you have unit tests, CSC tests, and CSCI tests. You are doing unit tests and CSCI tests. The CSC test is essentially a process test where you would test out the functionality of a process before you put it into the overall application. For example, you have a working application and write a new piece of functionality for that application. You unit test the code first. If everything works then you test the new functionality standalone. If that all works then you put it together with the application and test everything all together.

你几乎可以把它想象成你想到的方式。如果您愿意,可以添加并执行其他步骤并进行流程测试。在测试中,您有单元测试,CSC测试和CSCI测试。您正在进行单元测试和CSCI测试。 CSC测试本质上是一个过程测试,您可以在将其放入整个应用程序之前测试过程的功能。例如,您有一个工作应用程序并为该应用程序编写一个新功能。您首先对代码进行单元测试。如果一切正常,那么您可以独立测试新功能。如果这一切都有效,那么你将它与应用程序放在一起并测试所有内容。

These can all be the same tests if they cover the functionality. You may need to expand the tests the further you go in the testing though.

如果它们涵盖功能,这些都可以是相同的测试。您可能需要在测试中进一步扩展测试。

#1


3  

Pretty much. The important thing to know is that unit testing (in TDD) is not much about testing as it's about design. You create unit test to incorporate design decisions of every single component of code in an automated validation system; so that each part of your system conforms to its design. This way, you can rely on each component is not relying on unspecified features of other components.

差不多。重要的是要知道单元测试(在TDD中)并不是关于测试,而是关于设计。您可以创建单元测试,以在自动验证系统中合并每个代码组件的设计决策;以便系统的每个部分都符合其设计。这样,您可以依赖每个组件而不依赖于其他组件的未指定功能。

#2


2  

You can pretty much think of it the way that you are thinking of it. You could add and additional step if you wanted to however and do a process test. In testing you have unit tests, CSC tests, and CSCI tests. You are doing unit tests and CSCI tests. The CSC test is essentially a process test where you would test out the functionality of a process before you put it into the overall application. For example, you have a working application and write a new piece of functionality for that application. You unit test the code first. If everything works then you test the new functionality standalone. If that all works then you put it together with the application and test everything all together.

你几乎可以把它想象成你想到的方式。如果您愿意,可以添加并执行其他步骤并进行流程测试。在测试中,您有单元测试,CSC测试和CSCI测试。您正在进行单元测试和CSCI测试。 CSC测试本质上是一个过程测试,您可以在将其放入整个应用程序之前测试过程的功能。例如,您有一个工作应用程序并为该应用程序编写一个新功能。您首先对代码进行单元测试。如果一切正常,那么您可以独立测试新功能。如果这一切都有效,那么你将它与应用程序放在一起并测试所有内容。

These can all be the same tests if they cover the functionality. You may need to expand the tests the further you go in the testing though.

如果它们涵盖功能,这些都可以是相同的测试。您可能需要在测试中进一步扩展测试。