Let us suppose that we have a GUI-based Python tkinter application that takes the text input from the user and validates by saving it in a new text file. The file contains the same text input that the user has typed. We can check and validate the user input from the file.
In Functional Testing, we are primarily concerned about backend API, database, user-server communication, Input and output, etc.
To check the application using the functional testing strategy, we have to first understand the user requirement and the input/output. After testing the pre-phase, we test our application for different test cases.
For example, we have a GUI-based tkinter application that takes the user input and saves it in the form of a text file in the system.
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()
Running the above code will create a window like this,
Once we will click the Save the File button, it will save the filename as “Tutorials.txt”.
Now, go to the file location and open the text file externally. It will have the same text as the user input.