Python Testing Cookbook.: Easy solutions to test your Python projects using test-driven development and Selenium, 2nd Edition
暫譯: Python 測試食譜:使用測試驅動開發和 Selenium 測試 Python 專案的簡易解決方案(第二版)
Greg L. Turnquist, Bhaskar N. Das
- 出版商: Packt Publishing
- 出版日期: 2018-06-29
- 售價: $1,860
- 貴賓價: 9.5 折 $1,767
- 語言: 英文
- 頁數: 396
- 裝訂: Paperback
- ISBN: 1787122522
- ISBN-13: 9781787122529
-
相關分類:
Python、程式語言、selenium、TDD 測試導向開發
海外代購書籍(需單獨結帳)
相關主題
商品描述
Fix everyday testing problems in Python with the help of this solution-based guide
Key Features
- Use powerful tools such as doctest and unittest to make testing convenient
- Apply automation testing to an existing legacy system that isn't test oriented
- A practical guide to ease testing in Python using real-world examples
Book Description
Automated testing is the best way to increase efficiency while reducing the defects of software testing. It helps find bugs in code easily and at an early stage so that they can be tackled efficiently. This book delves into essential testing concepts used in Python to help you build robust and maintainable code.
Python Testing Cookbook begins with a brief introduction to Python's unit testing framework to help you write automated test cases. You will learn how to write suitable test sets for your software and run automated test suites with Nose. You will then work with the unittest.mock library, which allows you to replace the parts of your system that are being tested with mock objects and make assertions about how they have been used. You will also see how to apply Test-driven Development (TDD) and Behavior-driven Development (BDD) and how to eliminate issues caused by TDD. The book explains how to integrate automated tests using Continuous Integration and perform smoke/load testing. It also covers best practices and will help you solve persistent testing issues in Python. The book concludes by helping you understand how doctest works and how Selenium can be used to test code efficiently.
What you will learn
- Run test cases from the command line with increased verbosity
- Write a Nose extension to pick tests based on regular expressions
- Create testable documentation using doctest
- Use Selenium to test the Web User Interface
- Write a testable story with Voidspace Mock and Nose
- Configure TeamCity to run Python tests on commit
- Update project-level scripts to provide coverage reports
Who This Book Is For
If you're a Python developer who wants to take testing to the next level and would like to expand your testing skills, this book is for you. It is assumed that you have some Python programming knowledge.
Table of Contents
- USING UNITTEST TO DEVELOP BASIC TESTS
- RUNNING AUTOMATED TEST SUITES WITH NOSE
- CREATING TESTABLE DOCUMENTATION WITH DOCTEST
- TESTING CUSTOMER STORIES WITH BEHAVIOR DRIVEN DEVELOPMENT
- HIGH LEVEL CUSTOMER SCENARIOS WITH ACCEPTANCE TESTING
- INTEGRATING AUTOMATED TESTS WITH CONTINUOUS INTEGRATION
- MEASURING YOUR SUCCESS WITH TEST COVERAGE
- SMOKE/LOAD TESTING―TESTING MAJOR PARTS
- GOOD TEST HABITS FOR NEW AND LEGACY SYSTEMS
- Web UI testing using Selenium
商品描述(中文翻譯)
透過這本以解決方案為導向的指南修正日常測試問題
主要特點
- 使用強大的工具如 doctest 和 unittest 使測試變得方便
- 將自動化測試應用於不以測試為導向的現有遺留系統
- 使用真實世界範例的實用指南以簡化 Python 測試
書籍描述
自動化測試是提高效率並減少軟體測試缺陷的最佳方法。它有助於在早期階段輕鬆找到程式碼中的錯誤,以便能夠有效地解決這些問題。本書深入探討在 Python 中使用的基本測試概念,幫助您構建穩健且可維護的程式碼。
《Python 測試食譜》首先簡要介紹 Python 的單元測試框架,幫助您編寫自動化測試案例。您將學習如何為您的軟體編寫合適的測試集,並使用 Nose 執行自動化測試套件。接著,您將使用 unittest.mock 庫,該庫允許您用模擬物件替換正在測試的系統部分,並對其使用方式進行斷言。您還將看到如何應用測試驅動開發(Test-driven Development, TDD)和行為驅動開發(Behavior-driven Development, BDD),以及如何消除由 TDD 引起的問題。本書解釋了如何使用持續整合(Continuous Integration)整合自動化測試並執行煙霧測試/負載測試。它還涵蓋最佳實踐,幫助您解決 Python 中持續存在的測試問題。本書最後幫助您理解 doctest 的運作方式,以及如何有效地使用 Selenium 測試程式碼。
您將學到什麼
- 從命令行運行測試案例並增加詳細程度
- 編寫 Nose 擴展以根據正則表達式選擇測試
- 使用 doctest 創建可測試的文檔
- 使用 Selenium 測試網頁用戶介面
- 使用 Voidspace Mock 和 Nose 編寫可測試的故事
- 配置 TeamCity 在提交時運行 Python 測試
- 更新專案級別的腳本以提供覆蓋報告
本書適合誰
如果您是希望將測試提升到新層次並擴展測試技能的 Python 開發者,本書適合您。假設您具備一定的 Python 程式設計知識。
目錄
- 使用 unittest 開發基本測試
- 使用 Nose 執行自動化測試套件
- 使用 doctest 創建可測試的文檔
- 使用行為驅動開發測試客戶故事
- 使用驗收測試進行高層次客戶場景
- 與持續整合整合自動化測試
- 通過測試覆蓋率衡量您的成功
- 煙霧/負載測試 - 測試主要部分
- 新系統和遺留系統的良好測試習慣
- 使用 Selenium 進行 Web UI 測試