What Is Functional Testing? Examples, Types, and How It Differs From End-to-End Testing

What is functional testing? A plain definition, its types, a worked example, how it differs from end-to-end testing, and how to automate it without code.

By Ait Nohaila, Business Development Representative 9 min read

Functional testing checks that each function of an application does what it should: for a given input, the result is the expected one. It looks at what the app does, not at how it is built.

The people who know best what each function should do are the testers and the product owners. Yet when functional tests are written as code, they need a programmer to write them, and another afternoon of repairs each time a screen changes.

What is functional testing?

Definition

Functional testing is testing an application against what it is supposed to do.

  • A tester gives a function an input, such as a click, a value or a file, and compares the result with the expected one.
  • The test does not care how the code is written, only that the behaviour is right.

That is why it is often called black-box testing: the tester looks at the box from the outside.

Input

SAVE10

typed in the code field, then Apply

Expected result

$90.00

the total a 10 % discount should give

Actual result

$90.00

the total the screen shows

Expected and actual are the same: the test passes.

A functional test is always the same three things: an input, the result that should follow, and the result that did.

The expected result comes from the requirements: a specification, a user story, or the plain sentence a product owner would say. A 10 % code on a $100.00 cart gives a total of $90.00. If the screen shows anything else, the function has a bug.

Functional testing vs non-functional testing

The two answer different questions about the same feature.

What to compareFunctional testingNon-functional testing
The questionDoes it do the right thing?Does it do it well enough?
It is based onThe requirements: what the feature should do.The qualities: how fast, how safe, how easy to use.
ExamplesThe discount is applied, the order is saved, the error message appears.The page loads in time, the app holds under load, the screen works on a phone.
It passes whenThe result is the expected result.A measure stays within its limit.

The types of functional testing

The types differ in two ways: how much of the application a test looks at, and when it runs.

TypeWhat it checksWho usually writes it
Unit testingOne function of the code, alone.Developers
Integration testingTwo or more parts working together.Developers
System testingThe whole application, assembled, against its requirements.Testers
Acceptance testingThat the application does what the business asked for.Testers, product owners, customers
Smoke testingThat a new build starts and its main features respond.Testers, then a pipeline
Regression testingThat a change broke nothing that already worked.Testers, then a pipeline

The first four are sizes, from the smallest piece to the whole product.The last two are moments: see smoke vs sanity vs regression testing for when each runs, and what is regression testing for the longest of them.

A functional testing example: a discount code field

Take one small function of an online shop: the field where a customer types a discount code. The requirement fits in a sentence: the code SAVE10 takes 10 % off the cart. A tester turns that sentence into cases.

CaseInputExpected result
A valid codeSAVE10 on a cart of $100.00A message says the discount is applied, and the total reads $90.00.
An unknown codeSAVE99A message says the code is not valid, and the total stays $100.00.
An expired codeA code from last summerA message says the code has expired, and the total stays $100.00.
An empty fieldApply, with nothing typedA message asks for a code, and nothing is applied.
Small letterssave10The code is accepted like SAVE10.
The same code twiceSAVE10, then SAVE10 againThe discount is applied once only.
One sentence of requirement, six cases. The cases nobody wrote down are where the bugs hide.

Notice that only the first case is the one a demo shows. The other five are the ones a customer finds, which is why a functional test checks what should not work as carefully as what should.

How functional testing is done, in four moves

  1. Requirement

    What it should do

  2. Test cases

    Inputs and results

  3. Run

    Do it on the app

  4. Compare

    Expected vs actual

The first two moves need someone who knows the product. The last two are the same at every build, for every case, for the life of the application. That repetition is what makes functional testing worth automating.

Functional testing vs end-to-end testing

A functional test checks one function against what it should do. An end-to-end test follows a whole workflow through the real screen, from the first click to the final result. They are not opposites: one is a kind of the other.

One function

The discount code field accepts a valid code.

One screen

The cart shows the right items, the discount and the total.

One whole workflow

A customer signs in, fills the cart, applies the code, pays and gets a confirmation.

All three are functional tests. The last one is also an end-to-end test: it is the widest a functional test can be.
What to compareA functional test of one functionAn end-to-end test
What it followsOne function, one case.A whole workflow, as a user goes through it.
What it needsThe screen of that function.Every part the workflow crosses, working together.
When it failsYou know which function and which case.You know the workflow is broken, and the report says at which step.
How many you keepMany: one per case.Few: one per workflow the business cannot lose.

Many end-to-end tests are functional tests at the widest scope.What is end-to-end testing follows one real workflow from start to finish, and end-to-end testing vs integration testing shows what only a test of the real screen can see.

Why functional tests written as code leave testers out

Automating the six cases above usually means writing them as code, and that changes who can do it.

  • A script is written by someone who programs, not by the tester who knows the function.
  • Each field and button is found through a locator in the code, which breaks when the screen is reworked.
  • Waiting for the new total takes wait code, or a fixed pause that is sometimes too short.
  • A new expected message is an edit to code, queued behind feature work.
What a case needsIn a coded frameworkIn GUI Test Studio
Creating itA script per case, in a framework such as Selenium, Playwright or Cypress.The tester does the case once while it is recorded.
Finding the field and the buttonA locator in code, repaired when the screen changes.Found through the app's accessibility information, or by sight.
Waiting for the resultWait code, or a fixed pause.Every check waits by itself, up to its timeout.
Changing the expected resultAn edit to code, by a programmer.An edit of the check's expected text, by the tester.

The result is familiar: the cases stay manual, and they are run less and less often.Manual testing vs automated testing shows what that costs at every release.

Functional testing without code: record the function once

GUI Test Studio automates end-to-end tests of any app without code, and a functional test of one function is the shortest test it makes. Here is the first case of the discount code, from nothing to a test that runs by itself.

  1. 1

    Put the app where the function starts

    Open the cart with one item of $100.00 in it. A test replays from the state it was recorded in, so decide this starting point before you record.

  2. 2

    Record the case once

    Click Record in GUI Test Runner-Recorder. Type the code SAVE10, click Apply, wait for the new total, then press Esc to stop.

  3. 3

    Choose what the test verifies

    Answer the question What should this test verify. Leave the visual checks and the checks of what appears switched on, and switch on Verify Text so words are checked as words.

  4. 4

    Make the expected result exact

    Open the test in GUI Test Studio. Drag a Text Assert from the Assertions palette to the moment the message shows, and mark the message on the frame. Do the same for the total. Give a value that changes at every run, such as the time, a Dynamic Text Assert.

  5. 5

    Run it and read the report

    Click Run Test. The Confidence Report lists each check, with what was expected beside what was found, and says why a check failed.

  6. 6

    Record the other cases the same way

    An expired code, an empty field, the same code twice: each case is a short test of its own. The steps that open the cart can be a Scenario that every case reuses.

A Text Assert in its editor: mark the words on the recorded screen, and the editor says at once whether a run would find them.

You can also describe the case in a prompt to your AI assistant, and the test is recorded for you: see Create a test from a prompt.Either way, the test replays by itself afterwards: no AI drives your app during a run, so the same test on the same app gives the same answer.

Which check for which expected result?

An expected result is always something the screen shows, or stops showing. Each kind has its check.

The screen after a valid code

SAVE10Apply

Discount applied

Subtotal$100.00

Discount-$10.00

Total$90.00

Updated today at 14:02

Text Assert

The message says the discount is applied.

Text Assert

The total reads $90.00.

Visual Assert

The green tick is shown beside the code.

Dynamic Text Assert

The time of the change is a time, whatever its value.

Each thing the screen shows gets the check that fits it: words are read, a look is compared, and a value that changes is checked by its kind.
What you expectThe check
Words appear: a message, a label, a total you knowA Text Assert reads the words on the screen.
Words must not appear: an error messageA Text Absent Assert passes once they are gone.
A value that changes at every run: a date, a time, an order numberA Dynamic Text Assert checks the kind of value, not the value.
An element looks right: an icon, a button, a colourA Visual Assert compares its look, the way a person would.
Something is gone: a spinner, a closed dialogA Visual Absent Assert waits until it has left the screen.
Things stand where they belongA Layout Assert checks the arrangement.

Every check waits for what it expects and passes the moment it is there, so no pause has to be guessed.Choose the right check helps you pick one in a sentence, and Text checks explains the text ones in full.

Run the functional tests on every build

A functional test earns its keep when it runs again at every change. On a build machine, gtr-cli runs the recorded tests from any CI/CD tool, fails the build when a test fails, and keeps each run's report, video and pictures.

Every case of the discount code, on every build
gtr-cli run tests\discount --countdown 0 --junit results\functional.xml

When a case fails, the Confidence Report shows the expected result beside the actual one, so the question a functional test asks is answered on one screen.How to read a test report goes through it, and Run tests in your pipeline lists the options of gtr-cli.

What to know before you start

LimitWhat it means
Through the screen onlyGUI Test Studio tests what is shown on a Windows screen. It does not replace the unit tests developers write for the code itself.
The same starting pointA test replays from the state it was recorded in. A cart that already holds a discount makes the first case fail.
A test checks what it was told to checkIf no check looks at the total, a wrong total passes. Each case ends on a check of its expected result.

Key takeaways

  • 1Functional testing checks what an application does: an input, an expected result, and a comparison with the actual one.
  • 2Non-functional testing checks how well it does it, and comes after the function works.
  • 3The types are sizes and moments: unit, integration, system and acceptance by size, smoke and regression by moment.
  • 4An end-to-end test is a functional test at the widest scope: a whole workflow through the real screen.
  • 5Written as code, functional tests leave testers out. Recorded with GUI Test Studio, the tester makes them and they run on every build.

Questions

What is functional testing in simple words?

Functional testing checks that each function of an application does what it is supposed to do. A tester gives the function an input and compares the result with the expected one, without looking at how the code is written.

What is the difference between functional and non-functional testing?

Functional testing checks what the application does: the discount is applied, the order is saved. Non-functional testing checks how well it does it: how fast, how safe, how usable. A feature can pass every functional test and still be too slow to use.

What are the types of functional testing?

The main types are unit, integration, system and acceptance testing, which differ in how much of the application they look at. Smoke testing and regression testing are functional too. They differ in when they run and why.

Is end-to-end testing a type of functional testing?

Mostly, yes. An end-to-end test follows a whole workflow through the real screen and checks that it does what it should, which makes it a functional test at the widest scope. It is the functional test closest to what a user really does.

What is an example of functional testing?

A discount code field is a good example. The tester types a valid code and checks that the total drops by the right amount, then tries an expired code, an unknown code and an empty field, and checks the message each one gives.

Is functional testing manual or automated?

It can be either. A new function is usually tested by hand first, while it is still changing. Once it works, its cases are worth automating, because they must be checked again at every build.

Is functional testing the same as black-box testing?

Usually, yes. A functional test is designed from what the application should do, not from its code, which is the idea of black-box testing. Unit tests are the exception: developers write them with the code in front of them.

Can functional tests be automated without writing code?

Yes. With GUI Test Studio, a tester does the case once in the application while it is recorded, then chooses what the screen must show. The test replays by itself on every build, and no test code is written or maintained.

Selenium, Playwright, Cypress and Windows are trademarks of their respective owners.

All articles