Giả sử app Tkinter nhận input text, lưu vào file text. Functional testing kiểm tra: backend, database, I/O, user-server communication.
Quy trình: hiểu yêu cầu -> test các test case. Ví dụ: app nhập tên file và nội dung, lưu file .txt.
Ví dụ
from tkinter import *
win = Tk()
win.geometry("700x600")
Label(win, text="Enter the File Name").pack(anchor='n')
title_entry = Entry(win, width=35)
title_entry.pack(anchor='nw')
def save():
file_title = title_entry.get()
file_contents = text_entry.get(0.0, END)
with open(file_title + ".txt", "w") as file:
file.write(file_contents)
print("File successfully created")
file.close()
Button(win, text="Save The File", command=save).pack()
text_entry = Text(win, width=40, height=30, border=4, relief=RAISED)
text_entry.pack()
win.mainloop()Kết quả
Chạy code tạo cửa sổ nhập tên file và nội dung.

Click "Save The File" lưu file "Tutorials.txt". Mở file bên ngoài thấy nội dung giống input.
