Skip to Content
Python 技術手冊 第三版
book

Python 技術手冊 第三版

by lex Martelli, Anna Martelli Ravenscroft, Steve Holden
January 2018
Intermediate to advanced
856 pages
17h 17m
Chinese
GoTop Information, Inc.
Content preview from Python 技術手冊 第三版
510
|
16 章 測試、除錯和最佳化
所有的這些任務都是大工作而且很重要,而每個都至少能寫成一本書。本
章不會討論相關的每個技巧和後果,而是專注在 Python 限定的技巧、方法
和工具。
測試
在本章中,我們會區分不同種類的測試:單元測試(unit testing)和系統
測試(system testing)。測試是一個內涵豐富的重要領域:還能以許多不同
的方式區分,但我們專注在對軟體開發人員最為重要的議題上。有許多開
發人員不願意花時間在測試上,認為它會浪費「真正的」開發時間,但這
是一種短視的行為:你越早找到缺陷,就越容易修補它們,如果能盡快找
到缺陷,測試所帶來的回報,就足以彌補花在上面的時間還有剩,這能節
省在軟體開發週期後面階段需要花在除錯上的大量時間。
單元測試和系統測試
單元測試
unit testing
代表撰寫並執行針對單一模組的測試,或甚至是
更小的單元,例如一個類別或函式。
系統測試
system testing
,也叫做
整合
端對端
測試)是以已知的輸入執行整個程式。關於測試的某些
經典書籍也會區分在知道程式內部運作方式下進行的
白盒測試
white-box
testing
,和沒有這種知識下所進行的
黑盒測試
black-box testing
。這種
傳統的觀點接近但不完全等同於現代對於單元測試 vs. 系統測試的區分。
單元測試和系統測試的目標不同。單元測試隨著開發過程同步進行,你
可以也應該在開發每個單元時測試它。一個相對現代的做法(1971 年在
Weinberg 不朽的經典 ...
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

利用 Python 进行数据分析(原书第2版)

利用 Python 进行数据分析(原书第2版)

Wes McKinney

Publisher Resources

ISBN: 9789864766819