当前位置:网站首页>All you know is the test pyramid?

All you know is the test pyramid?

2022-06-24 08:12:00 ThoughtWorks China

Write it at the front

Test that pyramids used to exist like gods , Many people think that The test strategy know Test pyramids That's enough . Is that really the case ? today , Use this passage to talk with you Test pyramids .

If you happen to know the test pyramid , It is also regarded as the guideline of testing strategy , So this article is just right for you . If you don't know the test pyramid , But we are very concerned about quality and testing , So whatever your role is , This article is also suitable for you .

Most people know about the the Test Pyramid due to Mike Cohn, when he described it in his 2009 book Succeeding with Agile. In the book he refers to it as the “Test Automation Pyramid”, but in use it’s generally referred to as just the “test pyramid”. He originally drew it in conversation with Lisa Crispin in 2003-4 and described it at a scrum gathering in 2004. Jason Huggins independently came up with the same idea around 2006.

The test pyramid was first built by Mike Cohn Put forward ,Martin Fowler In the article TestPyramid There is a detailed introduction to . If you don't know the test pyramid , You can look at Martin The article .

In conclusion , The test pyramid is Automated test layering A reference model for coverage , Its characteristics are :

  • The tests at the bottom of the pyramid are the tests closest to the code —— unit testing , Low writing cost 、 Fast execution 、 Positioning problems are also more accurate , But it is far away from the business layer , Can not well reflect the business value ;
  • The test at the top of the pyramid is UI Automated testing of layers , This layer is close to the business , It can reflect the business process coverage , But the writing cost is high 、 Slow execution 、 Not stable enough 、 The positioning problem is also more difficult ;
  • And the integration test of the middle layer , The cost and value are in the middle .

therefore , The pyramid suggests that the bottom unit test should account for the most , And the top UI Layer testing accounts for less , The integration test of the middle layer is in the middle , Present the pyramid structure as a whole .

This is suitable for ideal projects , In the actual project, there may be many situations that are not suitable for testing the pyramid :

###1. Microservice architecture system
Dependency and connectivity between services in a microservice system , Is the key to microservice testing , Relatively speaking , The possibility of internal errors in the service is small . therefore , For automated testing under the microservice architecture, it should be Honeycomb structure or spindle shape , That is, the integration tests between the m-server services are the most , Unit tests at the bottom and at the top UI There are relatively few tests .

2. Legacy system transformation

To support new business forms , More and more traditional industries are transforming to digital , One of the problems we face is the need to transform the legacy systems of large-scale and complex businesses . This situation , It is generally not appropriate to write a large number of unit tests , Technology and capability may not allow , Instead, we should start from the top-level business , First, add the function test of the business layer as the basic guarantee , At the same time to write API Integration testing and appropriate unit testing . Coverage of the entire automated test , It may be presented as Ice Cream Cone Structure form .

3. Teams with mismatched personnel skills

Some teams may have developers busy developing and not involved in writing tests , Only testers are responsible for writing tests , And testers who want to write unit tests must be familiar with the underlying code implementation , It may be difficult , Usually you can only write more UI test .

Of course , This is not a healthy state , Although it exists objectively , But we don't advocate .

4. The test strategy cannot rely solely on the test pyramid

Take the test pyramid as the only reference specification for test strategy development , It's not appropriate . Don't just focus on the test pyramid , Just focus on the layering strategy behind the test pyramid , It's not enough .
Test layering theory is more a guide to automated test layering , The test strategy needs to consider and pay attention to many more factors than this , such as : Business risk 、 Quality objectives 、 Lead time …… Numerous , It needs to be determined according to the specific project .

If you just focus on what the automated test will test , No attention to Business risk , It is possible to focus on testing the wrong function , The wasted effort , Do more harm than good .

Last , The test pyramid is not everything , Don't stress the test pyramid .

Test layering is one of the guiding frameworks for test strategies , The other is to test the four quadrants . More about testing strategies , Welcome to the following article :


writing /Thoughtworks Lin Bingyu

Link to the original text : The test pyramid is not everything -Thoughtworks Insight

原网站

版权声明
本文为[ThoughtWorks China]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/175/202206240436133604.html