Types of Test测试的分类

本文介绍了软件测试的三种主要类型:单元测试、集成测试和端到端测试。单元测试关注代码的独立单元,执行速度快但不涉及外部依赖。集成测试验证代码单元与其依赖项之间的交互,提供更高级别的信心。而端到端测试通过用户界面驱动应用,虽然提供最大信心,但速度慢且易受UI变化影响。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Types of Test

Unit Test

Test a unit of application without its external dependencies. Such as Files, Databases, Message queues, web services and so on.

Unit Test exercise your code without and external dependencies. They are Cheap to write and Execute fast. You can run hundreds of them just in few seconds. In this way, you can verify that each building block in your application it’s working as it’s expected.

However,since you’re not testing these classes or components with their external dependencies,

you can’t get a lot of confidence in the reliability of your application. So, that’s when integration tests come to the rescue

Integration Test

Integration Test tests a class or a component with its external dependencies. It tests the integration of your application code with these concrete dependencies like Files, Databases and so on.

These tests take longer to execute, because they often involve reading or writing to a database, but they give you more confidence in the health of your application.

Traditionally an integration test is defined as a test that takes a few units or classes, and test their behavior as a whole. So based on this definition if you test 2 classes together some people believe you’re writing an integration test and not a unit test even if none of these classes talk to an external resource like a database.

Chances are you’ve heard this definition before now. This definition is a great recipe for writing fragile tests that are coupled your implementation detail, so as you change the implementation of your classes, these tests are going to break and you will end up wasting a lot of time, fixing that. Not only one they give you any values, but they actually slow you down. if you have done unit testing before an failed. Chances are you’ve followed this definition.

A unit test tests a class or multiple classes without their external dependencies, they test a unit of work.
An integration test tests a class or multiple classes with their external dependencies.

End to End Test

End to End test drives an application through its user interface.

There are specific tools built for creating end to end tests. One popular tool that you might have heard of is selenium, which allows us to record the interaction of a user with our application and then. Laid back and check if the application is returning the right result or not.

These tests give you the greatest amount of confidence about the health of your application, but they have 2 big problems.

he first problem is that they are very slow because they require launching the application and testing it through the UI. So every test is going to launch the application, potential log in, navigate to an internal page submit a form and inspect the results, is very slow.

The second problem is that there are very brittle, because a small enhancement to the application or a small change in the user interface can easily break these tests.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值