Functional testing helps software teams validate the correctness of the software functionalities they build, extend and maintain. Thanks to the automated functional testing, software teams can release software to production without fear of breaking software features.
This article will go through different aspects of functional testing and how you can leverage this fantastic method of automated software testing to test your software, including different types of API.
Table of Contents
- What is functional testing
- How to do functional testing
- What is non-functional testing
- Functional testing vs. non-functional testing
- Functional API testing example
- Benefits of automated functional testing
- Testfully benefits for API functional testing
- Demo: Functional API testing using Testfully
What is functional testing
Functional testing is a form of software testing (either manually or automated) and a variation of black-box testing. In black-box testing, the tester is not aware of the internals of the software under test.
The focus of functional testing is to verify the correctness of different software functionalities.
To validate the correctness of functionalities, QA teams consult product requirements and specification documents. The word functional does not mean that you are testing a function (method, procedure) of your module, package, or class in a programming language.
How to do functional testing
Start reading the product requirement & specification document to familiarise yourself with the functionalities and expected behavior. The chances are that the product requirements do not exist, or you don’t have access to it. In this situation, you can document the existing functionality and use it as the source of truth. While looking at the functionalities, make a list of the functionalities and how you expect them to work. Then, apply the below steps to all of the items in your inventory.
Create a test case for the functionality
Define the input data based on the functionality
Define the output data based on the functionality
Execute the test
Compare the expected & output data, they should be identical to each other, or the test should fail.
Testing how software functions under unhappy paths are as crucial as happy paths, and you must include unhappy paths in your functional testing.
What is non-functional testing
The functional aspect of the software is not the only area that requires software testing. For example, QA & software teams test the availability of an API under the expected load to make sure the API can handle the workload. As the name suggests, non-functional testing focuses on how the software operates rather than the system’s behavior. Examples of non-functional API testing are Loading testing, performance testing, security testing, recovery testing, stress testing, and volume testing.
Functional testing vs. non-functional testing
Functional and non-functional testings cover two equally important aspects of the software under test and complete each other. The table below lists the difference between functional testing and non-functional testing.
|Functional testing||Non-functional testing|
|Tests software’s functionalities against the requirements||Tests non-functional aspects, including performance, reliability, and security.|
|Functional testing can be done manually or by automation||Manual non-functional testing is not feasible|
|Answers “Would the software work as expected with this change?” question||Answers “Would the software work as good as before?” question|
|Uses product requirement & specification documents as the source of truth||Uses desired performance and availability metrics as the input|
Functional API testing example
In this part, we will go through one functionality available in almost any web API: user authentication, and token generation. Most APIs offer an endpoint (or a GraphQL query field, in GraphQL APIs) for authentication, a functionality that we should include in our API testing effort. I would break this functionality into two parts:
- Active users should be able to log in using a valid username & password
- The returned token can be used for authorization.
A functional test with two steps would be able to verify the mentioned expectation. Using your tool/framework of choice for functional testing:
- Define a test case called
Active users can log in and get a valid token JWT token
- Add the first step called
Active users should be able to log in using a valid username & password
- Configure the first step to send the request to the auth endpoint
- Verify that the response contains a token
- Add the second step called
The returned token can be used for authorization
- Pass the token from the first step to an endpoint that requires authorization
- Verify that the endpoint does not return an error
Our top 10 API testing mistakes article cover some of the most common mistakes in API testing.
Benefits of automated functional testing
On the surface, automating your functional tests gives you the agility you have always wanted to test & release your software. That said, speed is not the only benefit of automated functional testing.
- Your feedback cycle becomes faster
- Reduced time on software testing
- Reduces business expenses on software testing
- You can include tests in your CI / CD pipelines
- You can actively monitor your production API using functional tests
- Testing multiple environments using one set of tests become possible
Testfully benefits for API functional testing
Testfully was build from the ground up for API functional testing. Unlike many other available API testing tools, Testfully allows you to define both single and multi-step functional tests. Moreover, Testfully offers the following unique features for functional API testing:
- Run functional tests against multiple environments, including localhost
- Monitor production API functionalities using the same set of tests
- Add tests to any CI/CD pipeline using Testfully CLI
- Define functional test cases without writing a single line of code
- Run functional test in parallel for faster result turnaround
- Access to historical functional test results at any time
- A cloud-based solution that makes your tests available to your entire team
Demo: Functional API testing using Testfully
The below short video gives you a quick demo of Testfully’s functional API testing and monitoring features, including functional test creation, running tests in parallel, and scheduling test cases for API monitoring.
What’s the difference between functional & non-functional testing?
While functional testing is focused on software’s functionalities, non-functional testing is concerned about other aspects of software like security and performance.
Which one is more important? Functional or non-functional testing?
Functional and non-functional testing are both equally important, and you should try to exercise both practices. With that said, if you have resources to allocate to only one, we highly recommend focusing on functional testing as it delivers more value to you.
Can I use Postman for functional API testing?
Although you can use Postman for functional API testing, you will be very limited as Postman does not support multi-step tests that you will most probably need for functional testing. Testfully makes a great Postman alternative for functional testing & monitoring.
What is a happy path in software testing?
A happy path happens when the user takes the actions you expect them to take, and nothing goes wrong in between; that’s a happy path.
What is an unhappy path in software testing?
An unhappy path happens when the user takes actions you don’t expect them to take. For example, in an authentication scenario, a user may enter an invalid email address, and that’s a user entering an unhappy path.