編寫乙個函式,它接受兩個引數:乙個城市名和乙個國家名,這個函式返回乙個格式為city, country的字串,如santiago, chile, 將這個函式儲存在乙個名為city_functions.py的模組中。
建立乙個名為test_cities.py的函式......
def get_city_country(city, country):str = city.title() + ',' + country.title()
return str
test_cities.py輸出結果:import unittest
from city_function import get_city_country
class citiestestcase(unittest.testcase):
# 測試city的測試用例
def test_city_countyr(self):
city_country = get_city_country('santiago', 'chile')
self.assertequal(city_country, 'santiago,chile')
if __name__ == '__main__':
unittest.main()
ran 1 test in 0.003s
ok
單元測試 單元測試文章收藏
前言 前段時間公司計畫做自動化測試,自己也打算圍繞幾個點做相關調研,現在想想呢?其實對自動化測試的概念都還不是十分清晰,當時主要還是圍繞 單元測試 向qa小夥伴學習了一段時間,現由於公司重組,學習中斷,這裡簡單記錄一些單元測試好文,留待後續參考.什麼叫自動化測試?自動化測試覆蓋率?覆蓋率如何做到的?...
單元測試之Django單元測試
每個應用,自帶tests.py 整合在django的專案檔案裡,更多是開發人員寫django自動的測試執行 3.1 前後置方法執行特點 django.test.testcase類主要由前 後置處理方法和test開頭的方法組成 特點 繼承於django.test.testcase 測試用例都是test...
壓力測試和單元測試
壓力測試 adb shell monkey p 包名 v 次數 單元測試 需要測試的方法 public class test 測試的 public class testz extends androidtestcase 1 繼承androidtestcase類 2 在androidmanifest....