What is functional testing? Functional testing is software testing performed according to the functional requirements in order to ensure that the program runs in an expected way. Functional testing is also called black-box testing or data-driven testing. It only needs to consider the various functions that need to be tested, without considering the internal structure and code of the entire software. In short, functional testing is intended to find defects (aka bugs) in the software.
A functional bug refers to a problem, error, or hidden functional defect in computer software or programs that undermines normal operation. The existence of functional bugs can cause software products to fail to meet user needs. It also may have a great impact on user experience, application data, fund security, etc.
Why can functional bugs exist? It is because developers may mistakenly understand the software requirements specification, or there are coding defects, or other issues.
How is functional testing performed? Generally, testers need to compile the test plan and write test cases for each feature/functionality after understanding the software requirements. It needs to include both positive cases and negative cases in the test plan. After that they can start to test by executing the test plan.
Let’s look at how to perform functional testing for a common login form in a web application. Take the login form of Topcoder as an example.
We can see there are four elements (ignore the “Forgot your password?” link) here: one username/email field, one password field, “SHOW” button for the password field, and the “LOG IN” button.
Basically, there are positive test cases such as:
Login will be successful with valid username/password
Login will be successful with valid email/password
Placeholder text is presented by default for each text field
Password is masked by default
Password is revealed when hitting the “SHOW” button
“SHOW” button can be toggled (“HIDE” is shown)
“LOG IN” button is disabled by default
“LOG IN” button is enabled when both fields are not empty
Negative test case examples:
Invalid username (e.g. if the max allowed length of the valid username is N, the test data can be N+1 characters) and valid password
Invalid email and valid password
Empty username and empty password
Valid username and empty password
Valid email and empty password
Empty username and valid password
Let’s consider CRUD operations as another generic scenario, which is often seen in some management systems.
First of all, let’s observe elements on the page and think about what possible features are available. After that we can start to test basic features of a table - pagination, sorting by header columns (name, email, age, phone), checkbox for selecting single row and the “Select All” checkbox.
Then we can test the functionality of each button - “Add New Student”, “Delete”, “Edit” and “Trash” buttons on each row in the table.
While testing the functionality of adding/editing a student, we noticed that the UI is basically the same. In this case, we can share the test data.
Positive test cases for adding/editing a student are easy to find: make sure that each field value follows each field rule. Let’s think about the negative test cases:
Invalid Name: name with special chars, empty string, some white spaces, long name which exceeds the max length of the Name field, etc.
Invalid Email: an email which does not pass the general email regular expression check, empty string if this field is required, long Email, etc.
Invalid Age: negative values, zero or big values, empty if this field is required, decimal value, etc.
Invalid Phone: a number which does not pass the phone number regular expression check, empty string if this field is required, etc.
Testing for deleting functionality is simpler. Most of the time, there will be a confirmation popup for the user to answer before actually deleting the record(s) like shown below:
Confirm by clicking the “X” or “Cancel” button to cancel the deletion operation and make sure no records are deleted. Click the “Delete” button to check if the chosen records are deleted successfully.
To summarize, functional testing needs to thoroughly verify all functionalities of the software and find potential bugs in it. By providing both positive and negative test cases, it can help you make the software more stable and reliable.