March 2, 2020

Functional Testing Explained

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.

login

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:

  1. Login will be successful with valid username/password

  2. Login will be successful with valid email/password

  3. Placeholder text is presented by default for each text field

  4. Password is masked by default

  5. Password is revealed when hitting the “SHOW” button

  6. “SHOW” button can be toggled (“HIDE” is shown)

  7. “LOG IN” button is disabled by default

  8. “LOG IN” button is enabled when both fields are not empty

  9. etc.

Negative test case examples:

  1. 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

  2. Invalid email and valid password

  3. Empty username and empty password

  4. Valid username and empty password

  5. Valid email and empty password

  6. Empty username and valid password

  7. etc.

Let’s consider CRUD operations as another generic scenario, which is often seen in some management systems.

studentTable

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.

addEdit

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:

  1. Invalid Name: name with special chars, empty string, some white spaces, long name which exceeds the max length of the Name field, etc.

  2. Invalid Email: an email which does not pass the general email regular expression check, empty string if this field is required, long Email, etc.

  3. Invalid Age: negative values, zero or big values, empty if this field is required, decimal value, etc.

  4. 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:

deleteStudents

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.

Group 9
Group 9