Professional Documents
Culture Documents
เริ่มกันที่สว่ นฐานของ Pyramid กันก่อน นัน่ คือ Unit tests การทำ Unit tests นัน้ เป็นการ Test function ของการ
ทำงานในระดับ Unit หรือ คือ Test การทำงานในหน่วยเล็กทีส่ ุด เห็นได้ไวที่สดุ ว่าตรงไหนทำงานผิดพลาด แต่ไม่การันตี
นะครับ เพราะการทำ Unit Tests มันไม่ได้พว่ งการทำงานกับจุดอื่น เช่น Developer สร้าง Class Lamp ขึ้นมาแล้วภายใน
Class มี Method หรือ Function ในการเปิดไฟ turnOn() และ turnOff() สิง่ ที่ Unit tests จะทำก็คือเราจะ Test เป็น
Method ไปว่าสามารถทำงานได้อย่างถูกต้อง หรือ ไม่
ปัจจุบนั ที่นยิ มกันมักจะเป็นการทำ TDD (Test Driven Develop)
Integration Tests
ส่วนกลางของ Pyramid เป็นส่วนของ Integration Tests ในส่วนนี้ จะเป็นการ Tests ระดับของ Service ของเราเป็น
ส่วนทีไ่ ม่ใช่การทำ Test function เล็ก ๆ แล้ว แต่เป็นการ Test function ทัง้ function ที่เหล่านักพัฒนา Provide มาให้
ซึ่งในส่วนนี้ จะเป็นการรวมถึงการที่ Service จะต้องทำงานได้ สามารถไปเชื่อมต่อกับ Network, Database, Other
Service หรือ Party ต่าง ๆ ที่ Service ของเราควรทำได้
ยกตัวอย่าง เช่น Profile Service ของเราสามารถทำหน้าที่ Get Profile ของลูกค้าได้ด้วย REST API สิง่ ที่ เราจะทำใน
Integration Tests ก็คือ การยิง API เข้าไป โดยที่เรา เตรียม Test Scenario เอาไว้วา่ จะต้อง Get ได้ ก็ต้อง Get ได้ โดย
ที่ไม่ได้สนใจเลยว่า Profile Service ของเรานัน้ ไปเอาข้อมูล Profile มาจากไหน Profile Service อาจจะไปขอข้อมูลมา
จาก Service อื่นอีกที มาประกอบกัน หรือ ต้องไปต่อ Database มา แล้วเอาข้อมูลมาประมวลผล ก่อนจะแสดงผลออกมา
ก็ได้…
การ Test แบบนี้ถา้ หาก API Get Profile เกิดมีปญ ั หาขึน้ มา QA, Tester จะทราบว่า API Get Profile มีปัญหา แต่
อาจจะรู้ หรือ ไม่รู้กไ็ ด้วา่ มีปญ
ั หาเพราะอะไร (ขึน้ อยู่กบั ความเก่งของ QA หรือ ไม่ก็ Developer เขียนบอกเอาไว้ ถ้า Error
แบบนี้มาจากอะไร ตรงนี้ยาว ข้ามนะครับ) ถ้าทำ automate test ในส่วนนี้ ก็จะทำให้รู้เร็วขึ้นว่ามันพัง หรือ ไม่ อย่างไร
แล้วบางทีอาจจะรู้เร็วกว่าเดิมด้วยซ้ำ เพราะว่าบางเคส automate อาจจะต้องไปหยิบของจาก database มาเทียบ
expect ค่าก็ได้
Top-down approach
This technique starts from the topmost module and gradually progress
towards the lower modules. Only the top module is unit tested in isolation.
After this, the lower modules are integrated one by one. The process is
repeated until all the modules are integrated and tested.
In the context of our figure, testing starts from Module A, and lower modules
B1 and B2 are integrated one by one. Now here the lower modules B1 and B2
are not actually available for integration. So in order to test the topmost
modules A, we develop “STUBS”.
“Stubs” can be referred to as code a snippet which accepts the inputs/requests from
the top module and returns the results/ response. This way, in spite of the lower
modules, do not exist, we are able to test the top module.
For Example Integration Test cases for Linkedin application will include:
• Verifying the interface link between the login page and the home page
i.e. when a user enters the credentials and logs it should be directed to
the homepage.
• Verifying the interface link between the home page and the profile page
i.e. profile page should open up.
• Verify the interface link between the network page and your connection
pages i.e. clicking accept button on Invitations of the network page
should show the accepted invitation in your connection page once
clicked.
• Verify the interface link between the Notification pages and say
congrats button i.e. clicking say congrats button should direct towards
the new message window.
Many integration test cases can be written for this specific site. The above
four points are just an example to understand what Integration test cases are
included in testing.
So, it’s not specific that integration testing is a black box or white box
technique.
System testing is a testing where the system as a whole is tested i.e. all the
modules/components are integrated together to verify whether the system
works as expected and no issues occur because of the integrated modules.