究竟什么是集成测试-与单元比较 [英] Exactly what is integration testing - compared with unit

查看:83
本文介绍了究竟什么是集成测试-与单元比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始在项目中使用单元测试,并编写在方法/功能级别进行测试的测试.

I am starting to use unit testing in my projects, and am writing tests that are testing at the method/function level.

我理解这一点,而且很有意义.

I understand this and it makes sense.

但是,什么是集成测试?从我阅读的内容来看,它把测试的范围扩大到测试应用程序的更大功能.

But, what is integration testing? From what i read it moves the scope of testing up to test larger features of an application.

这意味着我编写了一个新的测试套件,以测试更大的功能,例如(在电子商务站点上)结帐功能,用户登录功能,购物篮功能.所以在这里我要编写3个集成测试?

This implies that I write a new test suite to test larger things such as (on an e-commerce site) checkout functionality, user login functionality, basket functionality. So here i would have 3 integration tests written?

这是正确的-否则有人可以解释什么意思.

Is this correct - if not can someone explain what is meant.

此外,集成测试是否涉及ui(此处为Web应用程序上下文),并且会采用类似硒的方法来实现自动化.还是集成测试仍在代码级别,但将不同的类和代码区域捆绑在一起.

Also, does integration test involve the ui (web application context here) and would employ the likes of selenium to automate. Or is integration testing still at the code level but tying together difference classes and areas of the code.

推荐答案

考虑这样的方法PerformPayment(double amount, PaymentService service);

单元测试将是您为service参数创建模拟的测试.

An unit test would be a test where you create a mock for the service argument.

集成测试是一种使用实际外部服务的测试,以便您测试该服务是否正确响应了您的输入数据.

An integration test would be a test where you use an actual external service so that you test if that service responds correctly to your input data.

这篇关于究竟什么是集成测试-与单元比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆