मान लीजिए हमारे पास एक GUI-based Python tkinter application है जो user से text input लेता है और इसे new text file में save करके validate करता है। File में वही text input होता है जो user ने type किया है। हम file से user input check और validate कर सकते हैं।
Functional Testing में, हम primarily backend API, database, user-server communication, Input और output आदि के बारे में concerned होते हैं।
Functional testing strategy का उपयोग करके application check करने के लिए, हमें पहले user requirement और input/output समझना होगा। Pre-phase test करने के बाद, हम अपने application को different test cases के लिए test करते हैं।
उदाहरण के लिए, हमारे पास एक GUI-based tkinter application है जो user input लेता है और इसे system में text file के रूप में save करता है।
उदाहरण
from tkinter import *
win = Tk()
win.geometry("700x600")
# Create title label
title_label = Label(win, text="Enter the File Name")
title_label.pack(anchor='n')
# Create title entry
title_entry = Entry(win, width=35)
title_entry.pack(anchor='nw')
# Create save button and function
def save():
# Get contents of title entry and text entry
# Create a file to write these contents in to it
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()
pass
# Create a save button to save the content of the file
save_button = Button(win, text="Save The File", command=save)
save_button.pack()
# Create text entry
text_entry = Text(win, width=40, height=30, border=4, relief=RAISED)
text_entry.pack()
win.mainloop()
आउटपुट
उपरोक्त code चलाने से इस तरह की window बनेगी,

एक बार जब हम Save the File button पर क्लिक करेंगे, तो यह filename को "Tutorials.txt" के रूप में save करेगा।
अब, file location पर जाएं और text file को externally open करें। इसमें वही text होगा जो user input था।
