018第11章 TESTING YOUR CODE
💛20230118晨讀感言:
💔學習設置測試用例的語法需要一些時間來適應,但一旦你設置了測試用例,就可以直接為你的函數添加更多的單元測試。
💔至此,python 的基礎語法已經告一段落了,接下來就是 進入本書 第二階段:實作,本書有 三個 project 要實作,所以,每日晨讀內容進度將會 視 對程式的理解和實作進度 而有所不同。
💛晨讀摘要:
💚211 Unit Tests and Test Cases: A _unit test_ verifies that one specific aspect of a function’s behavior is correct. A _test case_ is a collection of unit tests that together prove that a function behaves as it’s supposed to, within the full range of situations you expect it to handle. A good test case considers all the possible kinds of input a function could receive and includes tests to represent each of these situations.
💚211 To write a test case for a function, import the unittest module and the function you want to test. Then create a class that inherits from unittest.TestCase, and write a series of methods to test different aspects of your function’s behavior.
from :《python crash course》