Chulalongkorn University Theses and Dissertations (Chula ETD)
Other Title (Parallel Title in Other Language of ETD)
Generating RESTful API test scripts with database constraints from openAPI specification
Year (A.D.)
2024
Document Type
Thesis
First Advisor
ธาราทิพย์ สุวรรณศาสตร์
Faculty/College
Faculty of Engineering (คณะวิศวกรรมศาสตร์)
Department (if any)
Department of Computer Engineering (ภาควิชาวิศวกรรมคอมพิวเตอร์)
Degree Name
วิทยาศาสตรมหาบัณฑิต
Degree Level
ปริญญาโท
Degree Discipline
วิศวกรรมซอฟต์แวร์
DOI
10.58837/CHULA.THE.2024.1038
Abstract
ในปัจจุบันระบบซอฟต์แวร์นั้นเชื่อมต่อกันเพื่อพัฒนาประสบการณ์ของผู้ใช้งานและดึงดูดผู้ใช้งานใหม่ ๆ ด้วยเหตุนี้ผู้พัฒนาซอฟต์แวร์จึงจำเป็นต้องมีมาตรฐานในการแลกเปลี่ยนข้อมูลเพื่อปรับปรุงการทำงานจึงนำไปสู่การสร้างเอพีไอ ในการพัฒนาเอพีไอ เอพีไอได้มีเอกสารที่เป็นมาตรฐานเพื่อช่วยให้นักพัฒนาซอฟต์แวร์เข้าใจส่วนประกอบของเอพีไอ เช่น พารามิเตอร์ รีเควสต์บอดี รีซอร์ส และ เอ็นพอยต์ ทำให้กลุ่มผู้ก่อตั้งโอเพนเอพีไอพัฒนาข้อกำหนดโอเพนเอพีไอขึ้น นอกจากนี้ เอพีไอมักเชื่อมต่อกับฐานข้อมูลในรูปแบบของฐานข้อมูลเชิงสัมพันธ์ที่มีเงื่อนไขของฐานข้อมูลซึ่งรับประกันความถูกต้องของข้อมูลที่จัดเก็บ เมื่อพัฒนาเอพีไอ ผู้ทดสอบเอพีไออาจมีแนวทางที่แตกต่างในการสร้างกรณีทดสอบ ซึ่งอาจมีความแตกต่างในการสร้างกรณีทดสอบซึ่งนำไปสู่การสร้างกรณีทดสอบที่ไม่ครอบคลุม โดยเฉพาะอย่างยิ่งเกี่ยวกับกรณีทดสอบของเงื่อนไขของฐานข้อมูลงานวิจัยนี้ได้นำเสนอวิธีการในการสร้างสคริปต์ทดสอบสำหรับเรสฟูลเอพีไอโดยใช้ข้อกำหนดโอเพนเอพีไอและข้อมูลเมตาของฐานข้อมูลเชิงสัมพันธ์ที่มีเงื่อนไขของฐานข้อมูล ซึ่งประกอบไปด้วยกรณีทดสอบ 3 แบบ ได้แก่ กรณีทดสอบจากตัวอย่าง กรณีทดสอบแบบอ้างอิงกับข้อกำหนด และ กรณีทดสอบแบบอ้างอิงกับเงื่อนไขของฐานข้อมูล โดยสำหรับกรณีทดสอบแบบอ้างอิงกับเงื่อนไขของฐานข้อมูลครอบคลุม 5 เงื่อนไข ได้แก่ เงื่อนไขบังคับแบบตรวจสอบ เงื่อนไขบังคับแบบห้ามเว้นว่าง เงื่อนไขบังคับแบบไม่ซ้ำ เงื่อนไขบังคับแบบกุญแจหลัก และ เงื่อนไขบังคับแบบอ้างอิง ซึ่งวิธีการนี้จะสามารถนำไปใช้กับเครื่องมือทดสอบเอพีไอแบบอัตโนมัติช่วยให้ผู้ทดสอบซอฟต์แวร์ได้รับผลลัพธ์ที่รวดเร็วยิ่งขึ้น หลังจากการทดสอบเครื่องมือ พบว่าการสคริปต์ทดสอบและข้อมูลทดสอบสามารถนำไปใช้งานได้จริงโดยใช้ข้อกำหนดโอเพนเอพีไอและไฟล์ คอนเน็กชันสตริงของฐานข้อมูลโพสต์เกรสคิวเอล
Other Abstract (Other language abstract of ETD)
Nowadays, software systems are interconnected to enhance the user experience and attract new users. As such, software developers require a standard for exchanging information to streamline their work, leading to the creation of APIs. In APIs development, APIs have standardized documentation to help software developers understand their components, such as parameters, request bodies, responses, and endpoints. This is why the OpenAPI Initiative developed the OpenAPI specification. Moreover, APIs often connect with databases that store information. Relational databases have rules known as database constraints, which ensure the accuracy of stored data. When developing APIs, software testers may have a different approach to generating test cases, potentially leading to gaps in coverage, particularly regarding database constraints.This paper proposes an approach for generating RESTful API test scripts using the OpenAPI specification while considering relational databases and their constraints. The approach includes three types of test cases: sample-based test cases, specification-based test cases, and database constraint test cases. For database constraint test cases, the tests cover five types of constraints: check constraints, not null constraints, unique constraints, primary keys, and foreign keys. This approach will be compatible with automated API testing tools, allowing software testers to achieve results more quickly. After testing the tool, it was found that the test scripts and generated test data can be practically used by leveraging the OpenAPI Specification and a connection string file from PostgreSQL.
Creative Commons License

This work is licensed under a Creative Commons Attribution-NonCommercial-No Derivative Works 4.0 International License.
Recommended Citation
ยันต์เจริญ, นันทิพัฒน์, "การสร้างสคริปต์ทดสอบเรสฟูลเอพีไอด้วยเงื่อนไขของฐานข้อมูลจากข้อกำหนดโอเพนเอพีไอ" (2024). Chulalongkorn University Theses and Dissertations (Chula ETD). 74005.
https://digital.car.chula.ac.th/chulaetd/74005