所以我有一个系统已被分解为接口和实现,以允许模拟等。这一切都很棒,我可以测试所有的功能。 因为一切都有输入和输出。
现在,我的业务逻辑基本上是一个将整个系统连接在一起并指定事物如何流动的类。 我如何确保在特定点采取行动等?
我该如何测试这个商务舱?
So I have a system that has been broken down into interfaces and implementations to allow mocking etc. That is all great and I can test all the functions. Because everything has an input and output.
Now, my business logic is basically a class that ties this entire system together and specifies how things flow. How can I ensure that actions were taken at a specific point etc?
How can I test this business class?
最满意答案
如果它绑定整个系统可能你不需要进行单元测试。 它接缝更多的集成测试。
无论如何,如果您需要检查从业务类调用正确的步骤序列,您可以模拟业务类中使用的其他类(使用Mockito之类的库)并仅验证调用序列。
如果您需要真实数据来测试它,这不是单元测试,而是集成测试。
If it ties the entire system probably you don't need to unit test it. It seams more an integration test.
Anyway if you need to check that the right sequence of steps is called from your business class you can mock the other classes used from your business class (using libraries like Mockito) and verify only the sequence of calls.
If you need real data to test it this is not a unit test, but an integration test.
更多推荐
发布评论