It is has been a long few weeks away from the keyboard, but moving to a new home can be a very time consuming proposition. Regardless, it is great to be blogging again. For this week, I wanted to focus on some different types of automated testing other than unit testing that can help developers build more robust applications and improve both the speed and effectiveness of quality assurance. Specifically, this post is going to focus on functional testing.
Functional testing is composed of the tests that you write which are from the user’s point of view. A functional test is used to perform quality assurance on all or part of an application utilizing the user interface as a pathway to the application. In other words, we are mimicking the user’s behavior and testing to see if the desired result is produced. This can also be thought of as testing the application against business requirements and validating that the application is behaving as intended. Here are some questions that a functional test might be used to answer:
- When I fill out and submit the contact form, does the confirmation page get displayed?
- If I submit faulty login credentials, does the interface report an error?
- If I submit correct login credentials, am I directed to the administration page?
- If I click the ‘About us’ link, does the “About Us” page display?
Functional testing is used to make sure different parts of the application are working together properly. A functional test may access API’s, user interfaces, databases, third party extensions, security, and other elements of the application in an effort to verify that all is working as it should be. This is a much broader scope for a test than those who are familiar with unit testing might be accustomed to, since unit testing looks at the smallest blocks of code for testing, the individual unit. As opposed to these small, individual units (e.g. methods) in your application code, functional testing cuts across many different units and tests the application as it will be utilized at runtime. Functional testing is not a substitute for unit testing, since it tests a different facet of the application. Functional testing should be thought of as an additional element of a comprehensive quality assurance strategy for application development.
Think about functional & unit testing in the context of a race car. Many of the unit tests would be executed by the mechanics and pit crew. For example, the tire changers are making sure the wheels are in good order, the fueler is making sure the gas tank is full, the window washer is there to make sure visibility is at its best, and so on. Various other mechanics may specialize in the suspension system, safety equipment, the engine, etc. Using a mechanic or tire changer to test the overall operation of the car would be unproductive since neither of these are experienced in knowing how the car is supposed to run on the track. In this case, the proper method of performing a functional test would be to use the car’s driver, since the the driver will be able to provide the right feedback and validation to make sure the car is running the way it should.
When thinking about functional testing in a PHP application, here are some elements of the application that developers may want to consider creating automate test strategies for:
- Login Credentials
- Secured pages (admin areas, etc.)
- APIs (via direct navigation to a URL)
Functional testing of the above elements can be as simple as opening your browser and clicking every link, filling out every form, or navigating to each API URL that is contained within the application. While this meets the basic literal definition of functional testing, it is slow, cumbersome and very prone to user errors due to the fact that it relies on the tester to do the same thing the same way every single time. In today’s world we want to automate whatever we can to assure speed and consistency in the quality assurance process. Fortunately, such tools for streamlining functional testing do exist in the form of browser automation software.
This has been a basic overview of functional testing. In part 2, I will demonstrate the use of browser automation software to develop a testing suite that will make your functional testing strategy simple, repeatable, and efficient.
Best of luck in the meantime,