你可能会用单元测试框架,python的unittest、pytest,Java的Junit、testNG等。 那么你会做单元测试么!当然了,这有什么难的? test_demo.py def inc(x): return x + 1 def test_answer(): assert inc(3) == 4 inc() 是定义的一个被测函数, test_anserver() 用于测试上面的一段代码。 通过pytest运行上面的代码: > pytest test_demo.py ====================== test session starts ======================= platform win32 -- Python 3.7.1, pytest-5.0.1, py-1.8.0, pluggy-0.12.0 rootdir: D:\vipcn\demo plugins: cov-2.7.1, forked-1.0.2, html-1.20.0, metadata-1.8.0, ordering-0.6, parallel-0.0.9, rerunfailures-7.0, xdist-1.28.0, seleniumbase-1.23.10 collected 1 item test_demo.py . [100%] ==============