ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

Testing - Chapter 11-14 in SWE at Google (Edition 2)

2022-06-20 11:33:40  阅读:210  来源: 互联网

标签:Chapter 11 tests Google testing code test suite your


Testing Overview

Why to test?

Chapter 11 gives some reasons:

  • Find bugs early.
  • An equally important reason why you want to test your software is to support the ability to change. (change software with confidence)
  • The act of writing tests also improves the design of your systems. As the first clients of your code, a test can tell you much about your design choices. If new code is difficult to test, it is often because the code being tested has too many responsibilities or difficult-to-manage dependencies.
  • Improved documentation, good test suite are good documentation.
  • Simpler reviews
  • Teams can release new versions of their application with confidence.

What is a test?

  • A single behavior you are testing, usually a method or API that you are calling
  • A specific input, some value that you pass to the API
  • An observable output or behavior
  • A controlled environment such as a single isolated process
    Attention: A bad test suite can be worse than no test suite at all.

Story: GWS (Google web server)

Releases were becoming buggier, and it was taking longer and longer to push them out. Team members had little confidence when making changes to the service, and often found out something was wrong only when features stopped working in production.
To address these problems, the tech lead (TL) of GWS decided to institute a policy of engineer-driven, automated testing. Within a year of instituting this policy, the number of emergency pushes dropped by half.

Design a Test Suite

Image followed is the difference of small, medium and large size of a test.
image
Small tests must run in a single process. Cannot run a third-party program such like a database. Also, they are not allowed to sleep, perform I/O operations, or make any blocking calls. They are not allowed to access the network or disk (not strictly denied here).
The only remaining restriction is that medium tests aren’t allowed to make network calls to any system other than localhost. As we all know that the amount of unit level test is 80%, integration test is 15% and end-to-end test is 5%.

Testing at Google scale

  • Store almost every line of code in a single monolithic repo(monorepo https://semaphoreci.com/blog/what-is-monorepo)
  • No repo branching. Manage testing at this scale by using of a CI system. Key component: Test Automation Platform(TAP).
  • Each supported language at Google has one standard test framework and one standard mocking/stubbing library.

Fast testing

  • Avoid sleep() and timeout(), instead, using polling for a state transition with a frequency closer to microseconds.
  • The secret to living with a large test suite is to treat it with respect. Treat tests like production code.
  • Using techniques like parallelizing execution and using faster hardware.

标签:Chapter,11,tests,Google,testing,code,test,suite,your
来源: https://www.cnblogs.com/Sanhao99/p/16345716.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有