Python เบื้องต้นสำหรับการทดสอบโค้ด
Alexander Levin
Data Scientist
Command-Line Interface (CLI) - อินเทอร์เฟซที่ให้ผู้ใช้โต้ตอบกับโปรแกรมด้วยการพิมพ์คำสั่งในเทอร์มินัล
คำสั่งสำหรับรัน slides.py จาก CLI:
pytest slides.py
ความหมาย: "รัน framework pytest โดยใช้เทสจากโมดูล slides.py"
ผลลัพธ์ของเทส:

ผลลัพธ์ของเทส:

ผลลัพธ์ของเทส:

ผลลัพธ์ของเทส:

ผลลัพธ์ของเทส:



คำสั่งสำหรับรันเทสทั้งหมดใน tests_dir/:
pytest tests_dir/
ความหมาย: "รัน framework pytest โดยใช้เทสทั้งหมดที่พบในโฟลเดอร์ tests_dir"

คำสั่งสำหรับรันเทสจาก tests_ex.py ที่มีคำว่า "squared":
pytest tests_ex.py -k "squared"
ความหมาย: "รัน framework pytest โดยใช้เทสทั้งหมดจากสคริปต์ tests_ex.py ที่มีคำว่า squared"
ผลลัพธ์:

pytestscript_name.pydirectory_name/-k "keyword_expression"Python เบื้องต้นสำหรับการทดสอบโค้ด