
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Good example of functional testing a Python Tkinter application
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.
Example
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()
Output
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.
- Related Articles
- What is Non-Functional Testing? Types with Example
- Difference between Functional and Non-functional Testing
- How to bundle a Python Tkinter application including dependencies?
- What is Functional Testing (Types & Examples)?
- Banking Domain Application Testing
- Web Application Testing Checklist
- Web Application Testing Guide
- How to create a borderless fullscreen application using Python-3 Tkinter?
- Best Web Application Testing Tools
- Psychological Testing and Industrial Application
- Give one example of a good domestic fuel.
- What is the role of test automation in functional testing?
- Path Testing & Basis Path Testing with Example
- 20 Best Web Application Testing Tools
- Creating Tkinter full-screen application
