การใช้ Tags ใน Robot framework (2)

KakyKad
Jan 13, 2021

--

จากครั้งที่แล้วได้เขียนเรื่องการใช้ [Tags] ในแต่ละ Test case ไป

ในครั้งนี้จะมาเพิ่มเติมเรื่องการใช้ Tags ของใน Robot framework เพิ่มกัน นั่นคือ Default Tags ซึ่งการใช้งานนั้นง่ายมากๆ แค่เพิ่มคำว่า Default Tags ลงไป

Example

และเมื่อ run คำสั่ง robot ก็จะ run แต่ละ Test case ให้เราทั้งหมดเลย

robot checkout-success-template.robot

ผลลัพธ์ที่ได้ก็จะเหมือนเดิม คือมีการแบ่ง Tags ว่าอันไหน done หรือ not ready แต่ถ้า Test case ไหนไม่ได้ระบุชื่อ Tags เอาไว้จะถูกใส่ให้เป็น done ทั้งหมด ซึ่งเรายังสามารถเลือกใช้ include หรือ exclude ได้เหมือนเดิมนะ

นอกเหนือจาก Default Tags แล้วยังมี Force Tags อีกด้วย การทำงานเหมือนเดิม แต่ผลลัพธ์ใน Report จะเป็นตามชื่อ Tags ที่เรากำหนดใน Force Tags

Example

ผลลัพธ์ที่ได้

จะเห็นว่า Test case ของ Bicycle มีการกำหนด Tags ว่า not ready แต่เมื่อกำหนด Force Tags ใน Setting แล้วจะทำการติด Tags ของ Test case Bicycle ว่า done เพิ่มเข้าไปด้วย

จำนวนผลรวมใน Report ก็จะเปลี่ยนไป

Reference : https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#tagging-test-cases

--

--

KakyKad
KakyKad

Written by KakyKad

เขียนไปเรื่อย

No responses yet