Skip to Content
Googleのソフトウェアエンジニアリング ―持続可能なプログラミングを支える技術、文化、プロセス
book

Googleのソフトウェアエンジニアリング ―持続可能なプログラミングを支える技術、文化、プロセス

by Titus Winters, Tom Manshreck, Hyrum Wright, 竹辺 靖昭, 久富木 隆一
November 2021
Intermediate to advanced
684 pages
10h 37m
Japanese
O'Reilly Japan, Inc.
Content preview from Googleのソフトウェアエンジニアリング ―持続可能なプログラミングを支える技術、文化、プロセス

13章テストダブル

Andrew Trenk, Dillon Bly 著

Tom Manshreck 編

 ユニットテストは、開発者の生産性を保ちつつコードの欠陥を減らすために、決定的に重要なツールである。ユニットテストは単純なコード向けに書く分には簡単なこともあるが、コードの複雑性が増すにつれて書くのが難しくなっていく。

 例えば、外部のサーバーへリクエストを送信し、それからレスポンスをデータベースに保存するという関数に対し、テストを書こうとしていると想像してみよう。ある程度努力すれば、テストをいくつか書くくらいのことはできるかもしれない。しかしそうしたテストを何百何千と書かなければならないとすれば、テストスイートは実行に何時間もかかる可能性があるだろう。またランダムなネットワーク障害や、別のテストのデータを上書きするテストといった問題のせいで、信頼不能テストになってしまいかねないだろう。

 そのような場合には、テストダブルがおあつらえ向きである。テストダブル(test double)(https://oreil.ly/vbpiU)は、映画内でスタントマン(stunt double)が俳優の代役を務めるのと同じように、テスト内で本物の実装の代役を務めることのできるオブジェクトまたは関数である。テストダブルの利用はしばしばモッキング(mocking)と呼ばれるが、これから見ていくように、その用語はテストダブルのさらに個別具体的な側面を指す場合にも使われるために、本章ではモッキングという用語をテストダブル全般の利用を指すために使うのは避けている。

 テストダブルの最もわかりやすい類型はおそらく、メモリー内データベースのように、オブジェクトの単純化した実装で本物の実装同様に振る舞うものだ。テストダブルの別の類型として、稀なエラー条件を引き起こすのを簡単にしたり、重量級の関数の呼び出しが実際にその関数の実装を実行することなく確実に行われるようにしたりすることで、システムの特定の詳細部分を検証できるようにするものもある。 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

サイトリライアビリティワークブック ―SREの実践方法

サイトリライアビリティワークブック ―SREの実践方法

Betsy Beyer, Niall Richard Murphy, David K. Rensin, Kent Kawahara, Stephen Thorne, 澤田 武男, 関根 達夫, 細川 一茂, 矢吹 大輔, 玉川 竜司
初めてのSQL 第3版

初めてのSQL 第3版

Alan Beaulieu, 株式会社クイープ
プログラミングRust

プログラミングRust

Jim Blandy, Jason Orendorff, 中田 秀基
仕事ではじめる機械学習 第2版

仕事ではじめる機械学習 第2版

有賀 康顕, 中山 心太, 西林 孝

Publisher Resources

ISBN: 9784873119656Other