TECHTALK: Test Driven Development (TDD) Restful API dengan Mock Server Postman
Summary
TLDRThe video script introduces the concept of Test-Driven Development (TDD), a method in application development where tests are written before the actual code, leading to more directed and error-free code. It also covers Facebook FPI, a data exchange method using HTTP protocol, aimed at creating systems with good performance and ease of development. The script further explains the use of Postman as a tool for FPI development, highlighting features like collections, environments, mock servers, and automated tests, demonstrating how these can be utilized to streamline the development process and reduce miscommunication.
Takeaways
- 😀 The presenter introduces themselves as a back-end developer from a mission and finance department.
- 🔧 The main topic is Test-Driven Development (TDD), a software development method that combines programming, unit testing, and writing tests before coding.
- 📝 TDD aims to ensure that the developed program meets its intended purpose by writing tests first, which leads to a more focused development process.
- 🔄 The workflow of TDD involves writing test code first, running tests to ensure failure due to the absence of the actual code, then writing the program code to pass the tests, and repeating this cycle.
- 🆚 The difference between TDD and traditional development is highlighted, where traditional development writes code first and then tests it, whereas TDD inverts this process.
- 💡 Benefits of TDD include continuous testing, better design due to the test-first approach, avoidance of damage from refactoring, and reduced debugging for developers.
- 🛠️ The script discusses the use of FPI (Fake Payment Integration) with HTTP protocol for developing systems or applications with good performance and fast data transaction processes.
- 🌐 The process of FPI involves the client sending a request to the server, server authentication, processing the request, and returning a response with the necessary information.
- 🔧 The use of mock servers like Postman's Mock Server is explained for simulating real servers to help developers test and check FPI and its responses.
- 🛠️ Postman's features for API development are outlined, including collections for organizing requests, environments for storing variables, sample responses, mock servers, test scripts, automated tests, and documentation generation.
- 📚 A demo is provided on how to create a mock API for displaying a list of students using Postman, including setting up a collection, adding requests, creating mock responses, and writing test scripts.
Q & A
What does TDD stand for in the context of the script?
-TDD stands for Test-Driven Development, a software development approach where tests are written before the code, ensuring that the code meets the desired outcomes.
What is the primary purpose of Test-Driven Development (TDD) according to the script?
-The primary purpose of TDD is to make the development process more directed and ensure that the final program meets its intended purpose.
How does the script describe the process of TDD?
-The script describes the TDD process as writing test code first, considering all possible inputs and outputs, running the tests to check for failures, then writing the program code to pass the tests, and repeating the process until all tests are successful.
What is the difference between TDD and traditional development methods as mentioned in the script?
-In traditional development methods, code is written first, followed by testing and fixing errors if they occur. TDD, on the other hand, involves writing tests first and then writing code to pass those tests.
What are some benefits of using TDD mentioned in the script?
-Benefits of using TDD include continuous testing leading to better design, code that is easier to understand, and a reduction in errors due to early detection, resulting in cleaner and less complex code.
What does FPI stand for and what is its purpose in the script?
-FPI stands for Frontend to Backend Interface, a method of data exchange using the HTTP protocol, aimed at creating a system or application with good performance, easy development, and fast data transaction processes.
How does the script describe the workflow of FPI?
-The script describes the FPI workflow as the client sending a request to the server based on FPI documentation, the server authenticating the client, processing the request internally, and finally returning a response to the client with information about the success of the request and any requested data.
What is a mock server and how does it relate to FPI as per the script?
-A mock server is a simulated server used to test and check FPI and its responses. It helps developers in testing without needing the actual server, ensuring that the FPI format is consistent and reducing the chance of miscommunication.
What tools or applications are mentioned in the script for using as a mock server?
-The script mentions tools like Postman, Max Server, and Stop Light as examples of applications that can be used as mock servers for testing FPI.
Can you provide an example of a feature in Postman that helps in FPI development as described in the script?
-One feature mentioned in the script is 'Collection' in Postman, which allows developers to group and organize requests in a way that suits the project or model they are working on.
What is the significance of the 'Mock Server' feature in Postman as explained in the script?
-The 'Mock Server' feature in Postman allows developers to create a simulated server response that can be accessed from the internet, mimicking the actual server response, which aids in the development and testing process without the need for a real server.
Outlines
😎 Test-Driven Development (TDD) Methodology
This paragraph introduces the concept of Test-Driven Development (TDD), a software development technique that combines programming, unit testing, and refactoring. The speaker, a back-end developer, explains that TDD involves writing tests before the actual code, which helps in creating more directed and error-free code. The process includes defining all possible inputs and outputs, running the tests to initially fail due to the absence of the code, then writing the code to pass the tests, and finally repeating the process until all tests are successful. The benefits of TDD include continuous testing, better design, and avoiding damage during code refactoring, leading to cleaner and less complex code.
🔌 Facebook FPI and Its Development Tools
The speaker discusses Facebook FPI, a data exchange method using the HTTP protocol aimed at creating a system or application with good performance, ease of development, and fast data transaction processing. The FPI process involves a client sending a request to the server, server authentication, processing the request, and returning a response. The response includes information about the success of the request and any data requested by the client. The paragraph also introduces the concept of a mock server for testing FPI and mentions various tools like Postman, Max server, and Stoplight that can be used. Postman is highlighted for its features like collections, environments, sample responses, mock servers, script tests, automated tests, and documentation generation.
🛠️ Implementing FPI with Postman's Mock Server
This section provides a practical demonstration of how to use Postman to create a mock server for FPI development. The speaker guides through the process of adding a new request, setting up a base URL, and using the mock server to simulate responses. It includes creating a new collection, adding example responses, and writing test scripts in JavaScript to validate the mock server's responses. The demonstration also covers how to save changes and rerun tests to ensure the mock server's responses meet the expected criteria, such as status codes and JSON format.
📚 Conclusion on the Benefits of Using Mock Servers
The final paragraph concludes by emphasizing the advantages of using mock servers like Postman's for FPI development. These benefits include not needing to prepare a real server for mockups, enabling mobile or frontend developers to start implementing FPI without waiting for backend completion, and minimizing miscommunication regarding FPI format since all developers refer to the same mockup. The speaker apologizes for any shortcomings and thanks the audience, ending the video script with a sign-off in Arabic.
Mindmap
Keywords
💡TDD (Test-Driven Development)
💡PDB (Test Dragon Development)
💡FPI (Frontend to Backend Interface)
💡Postman
💡Mock Server
💡Script Testing
💡Environment
💡Collection
💡Documentation
💡Automated Test
💡API Endpoint
Highlights
Introduction to Test Driven Development (TDD) as a method used in application development.
TDD combines programming, unit testing creation, and requires writing tests before the actual code.
TDD aims to produce code that meets its intended purpose, making the development process more directed.
Explanation of the TDD process, starting with writing test code, ensuring all possible inputs and outputs are considered.
Running tests to ensure they fail initially due to the absence of the actual code.
Writing the program code to pass the tests and then re-running the tests to check for success.
Iterating the process of writing tests and code until all tests pass, ensuring the code meets expectations.
Difference between TDD and traditional development, where code is written first, then tested and corrected if errors occur.
Benefits of TDD include continuous testing, better design, and code that has already passed tests.
TDD helps avoid damage from refactoring code and allows for easier identification and correction of errors before release.
TDD makes development easier for developers as it reduces the need for repeated debugging.
Introduction to Facebook FPI as a data exchange method using the HTTP protocol for developing high-performance systems.
FPI's working process involves the client sending a request to the server, server authentication, and processing the request.
Use of mock servers like Postman Mock Server for simulating real servers to help developers test and check FPI responses.
Overview of tools and applications for FPI development, such as Postman, Max Server, Stop Light, and others.
Explanation of Postman features like collections, environments, sample responses, mock servers, test scripts, automated tests, and documentation.
Demonstration of creating a mock API for displaying a list of students using Postman.
Use of Postman's mock server feature to create a mock server based on a collection for front-end developers to implement FPI.
Advantages of using Postman's mock server include not needing a real server for mockups, faster FPI implementation, and minimizing miscommunication in FPI format.
Conclusion emphasizing the benefits of using Postman's mock server for streamlined development and communication.
Transcripts
[Musik]
Oke
bismillahirrohmanirohim Assalamualaikum
warahmatullahi wabarakatuh
sebelumnya Perkenalkan nama saya laluis
marhadi Saya dari tempat misi dan
keuangan
sebagai back and Developer
Pada kesempatan kali ini saya akan
menyampaikan
materi laptop tentang Test Driver
development ekskul PPI dengan memaksa
server
langsung saja Apa itu PDB
jadi pdd atau tes Dragon development
merupakan salah satu metode yang
digunakan dalam pengembangan aplikasi
metode ini mengkombinasikan pemrograman
pembuatan unit testing dan
dalam penerapan metode ini kita akan
membuat tes terlebih dahulu sebelum
menulis kode program
dengan membuat tes sebelum memulai
menuliskan kode program diharapkan
program yang dihasilkan nanti sesuai
dengan tujuan yang ada dicapai dengan
kata lain proses development akan lebih
terarah
selanjutnya cara kerja tdd
cara kerja terdiri sendiri dapat melihat
seperti pada gambar berikut yang pertama
sebelum menulis kode program Tuliskan
kode tesnya terlebih dahulu
pastikan kita memasukkan semua
kemungkinan yang dapat kita pikirkan
untuk input dan outputnya kemudian
jalankan tesnya dan
pastikan ketika menjalankan tes tersebut
hasilnya file ini dikarenakan belum ada
kode apapun yang kita buat untuk membuat
tesnya berhasil selanjutnya Tulis kode
program agar hasil tesnya flash atau
berhasil kemudian dijalankan tes dan cek
Apakah tesnya sudah berhasil jika belum
maka perbaiki kembali kode program sudah
kita tulis sampai memenuhi ekspektasi
dari tes tersebut selanjutnya
ulangi proses tersebut dari awal sampai
terakhir untuk positif yang lainnya
kemudian
perbedaan tes gerakan biasa
seperti pada gambar
untuk slow nya bisa kita lihat bahwa
ketika kita
mengembangkan aplikasi dengan
metode pada umumnya kita akan menuliskan
kode programnya terlebih dahulu baru
melakukan
testing dan memperbaiki kode program
tersebut jika terjadi kesalahan
Sedangkan untuk diri sendiri merupakan
kebalikan dari hal tersebut kemudian
kelebihan dan manfaat yang didapatkan
dari
satu
identifikasi ini dikarenakan kita sudah
melakukan
uji coba terus-menerus secara berulang
yang kedua desain yang lebih bagus
karena
edd adalah metode yang membantu membuat
kode lebih mudah dipahami Selain itu
kode yang ditulis merupakan kode yang
sudah lolos uji coba berdasarkan
equipment dari
yang ketiga menghindari kerusakan akibat
faktor saat melakukan reflektor kode Ada
kemungkinan kita akan mengalami masalah
atau error dengan sudah kita buat kita
bisa memperbaiki air tersebut sebelum
rilis karena peringatan akan muncul jika
ada kode yang bermasalah ketika kita
menjalankan
yang keempat mudah bagi developer Hal
ini dikarenakan developer tidak perlu
melakukan debugging berulang-ulang
karena kesalahan kode sudah bisa
dikurangi dari awal sehingga kemudian
dihasilkan bisa lebih clean dan tidak
begitu kompleks tetapi perlu diingat
untuk tdd tidak menjanjikan aplikasi
atau website yang kita buat dapat lebih
cepat terselesaikan karena jadi dia
hanya menjanjikan menjanjikan proses
development lebih terarah
rata-rata dari kita semua dengan
sudah tidak asing lagi
saya jelaskan sedikit Facebook FPI
merupakan metode pertukaran data yang
menggunakan protokol http tujuannya
adalah menghasilkan suatu sistem atau
aplikasi yang memiliki
performa yang baik mudah dikembangkan
atau
dan cepat dalam proses transaksi data
kemudian Bagaimana cara kerja
FPI cara kerjanya yaitu
client mengirimkan permintaan ke server
berdasarkan dokumentasi FPI untuk
memformat permintaan dalam format yang
dipahami oleh server
kemudian server mengautentikasi client
dan mengkonfirmasi bahwa klien memiliki
hak untuk membuat permintaan selanjutnya
server menerima permintaan dan memproses
secara internal
dan yang terakhir server mengembalikan
respon kepada client
respon berisi informasi yang
memberitahu klien jika permintaannya
berhasil dan termasuk Informasi apa saja
yang diminta klien selanjutnya kita
beralih ke server nox server itu sendiri
adalah fake server yang digunakan untuk
simulasi sebagai server sesungguhnya
untuk membantu developer untuk testing
dan
mengecek FPI beserta respon dari FPI
tersebut
berikut ada beberapa tool atau aplikasi
yang bisa kita gunakan sebagai most
server yaitu ada Postman Max server
kemudian stop light
selanjutnya
dan masih banyak lagi tapi Pada
kesempatan kali ini saya akan
menjelaskan
maksud server pada
semen Maksudnya teman-teman di sini
sudah sering menggunakan Postman Disini
saya akan menjelaskan sedikit
jadi Postman merupakan tool untuk
melakukan proses
development FPI yang mana untuk saat ini
masih banyak fitur-fitur yang
sangat membantu dalam proses festival
diantaranya ada collection
yaitu
pengelompokan request yang bisa disimpan
atau diatur dalam bentuk folder
memudahkan untuk pengelompokan request
sesuai dengan proyek ataupun model yang
sedang dikerjakan
selanjutnya environment semacam konflik
untuk menyimpan atribut dan atribut
tersebut dapat digunakan ataupun
dimanipulasi dalam proses request
kemudian ada sample respon merupakan
contoh respon dari FPI yang akan dibuat
developer dapat membuat
sebelum benar-benar mengimplementasikan
ke dalam proyek
fitur selanjutnya yaitu novel server
dengan fitur ini semoga VPN dibuat
menggunakan fitur example Respon yang
kemudian dapat diakses dari internet
kayaknya mau ke
layaknya tersebut sudah
diimplementasikan dan dideplay ke server
yang sesungguhnya
Lalu ada script test fitur ini digunakan
untuk melakukan
tes sesuai dengan kebutuhan
selanjutnya ada automated test
fitur ini menjalankan request dalam satu
collection secara otomatis
penggunaannya biasa digabung dengan
Script
yang terakhir ada dokumentation yaitu
dokumentasi FPI yang dapat di generate
otomatis sesuai dengan request yang
tersimpan dalam
satu collection
selanjutnya
mungkin Disini saya akan demo singkat
untuk membuat mod HPA untuk menampilkan
bisa contohnya itu menampilkan daftar
mahasiswa
langsung saja saya ingin ke Postman
terlebih dahulu
nah disini
jadi pertama kita membuat
misalkan collection baru
membuat koleksi baru contohnya
bunganya misalkan
selanjutnya
tambahkan request
Nah di sini
[Musik]
[Musik]
Nah di sini kita tambahkan
request urlnya Oh ya sebelumnya kita
perlu menyiapkan apa namanya
di sini
kita sediakan untuk
ada pqrl atau base url dari server kita
nanti kemudian base URL di sini
merupakan
server jadi ketika nanti misalkan
Kayaknya sudah selesai membuat
endpoint bisa di switch dengan
Nah di sini kita
coba tambahkan terlebih dahulu
kemudian
kita tambahkan
example di sini
Nah jadi example disini merupakan
respon yang akan diambil nanti oleh
Mouse server kita
cara kerjanya itu nanti dari Mouse
misalkan dari regresi url-nya
slash mahasiswa maka
di sini Kita juga mendapatkan
selanjutnya
pada tab no server di sini kita membuat
bonsai terbaru tinggal klik Create new
server
kemudian gunakan yang select NSS
Nah di sini kita memilih
collection kita yang sudah kita buat
tadi yaitu meng server tadi
untuk nama nya
langsung saja klik no server
nah di bagian refresh nya
di sini kita coba tambahkan tesnya
untuk tes scriptnya di sini ditulis
menggunakan JavaScript
kalau untuk lebih detailnya mungkin bisa
dicek di postingannya langsung
sini Misalkan kita akan membuat Describe
untuk mengecek responnya itu
dan
apa namanya responnya itu harus berupa
Jason
[Musik]
nah kurang lebih syntaxnya seperti ini
Coba kita peran
untuk
wisudanya kita isi terlebih dahulu
ini kita copy dulu
sedikit
Oh ya jangan lupa untuk menyimpan setiap
perubahan soalnya nanti
dia nggak bisa ke laptop
kemudian coba kita rem lagi
di sini
hasil yang kita dapatkan dari tesnya
yaitu untuk tes pertama berhasil karena
responnya sudah 200 kemudian
[Musik]
tes kedua itu gagal karena di sini
diminta untuk responnya itu berupa Jason
sedangkan
di Excel kita kita belum menambahkan
Nah di sini kita coba tambahkan
respon berupa daftar mahasiswa
langsung saja
di sini juga kita bisa menambahkan
header sesuai kebutuhan
di sini saya temukan saja untuknya
kemudian kita
simpan
Sekarang kita akan coba lagi
[Musik]
kita coba lagi
Nah di sini untuk semua tesnya sudah
berhasil responnya juga sudah 200
Kemudian untuk tes kedua
harus dalam bentuk desain sudah sesuai
di bodynya sudah kita bisa cek
jadi pada
sampai dengan tahap ini
sudah bisa untuk memulai
apa namanya
membuatnya dan juga
server yang asli sedangkan dari sisi
front and itu bisa langsung mencoba
untuk mengimplementasi
dari ini karena
nantinya akan mengacu pada
yang sudah kita bikin untuk handphonenya
jadi harusnya tidak ada pilihan
Nah mungkin itu untuk demo
kembali ke
untuk kesimpulannya
sebenarnya bisa diambil adalah dengan
menggunakan
fitur Mouse server dari Postman sebagai
sarana terjadi ada beberapa keuntungan
yang kita dapatkan antara lain tidak
perlu menyiapkan server untuk mockup
vganya kemudian
mobile atau pendek bisa memulai
implementasi FPI tanpa menunggu BKN
tidak baik ke server
dan yang terakhir meminimalkan
terjadinya Miss communication
format FPI karena pada proses
development semua developer akan mengacu
pada
mockup FPI tersebut
Mungkin itu saja yang bisa saya
sampaikan kurang lebihnya Mohon maaf
terima kasih assalamualaikum
warahmatullahi wabarakatuh
[Musik]
تصفح المزيد من مقاطع الفيديو ذات الصلة
ISTQB FOUNDATION 4.0 | Tutorial 11 | TDD, BDD, ATDD | DevOps and Testing | CTFL | TM SQUARE
ISTQB Agile Tester #39 - What is Test Driven Development (TDD) in Agile
Agile Process - Georgia Tech - Software Development Process
Max Pronko | Pronko Consulting | 10 Pitfalls with Test Driven Development for Magento teams
WHY YOU SHOULD USE LOW-CODE FOR YOUR ENTERPRISE BUSINESS APPS TODAY. FULL GUIDE UNDER 10 MIN
What is Unit Testing, Integration, UI Testing & Benefits
5.0 / 5 (0 votes)