Functional Testing vs Regression Testing: Which Tests Earn a Second Run?
Most regression tests are functional tests run again, so the hard part is choosing which ones. See the difference, then five questions for promoting a test.
Sprint planning has a ticket that says “add regression tests for login,” and someone asks whether those are different from the functional tests the team wrote last month. Usually they are the same tests. Functional testing is about what a test checks. Regression testing is about when it runs again.
So the call to make is which functional tests should run again after every change. You’ll leave able to sort any test into your regression suite or out of it, starting with a login test you can run yourself.
What you’ll learn
- Where functional and regression testing differ, from trigger to what a red result means
- A login test that catches a security regression, in Python that runs as written
- A five-question check for promoting a functional test into the regression suite
- Which tools cover each layer on web and mobile
Functional Testing vs Regression Testing at a Glance
The two terms describe one test from two angles, and knowing which angle you are on tells you what a red result means. The first time a login test runs, it is functional testing, because it checks that a new feature works. The same test, run after a change somewhere else, is regression testing, because it checks that the feature still works. Same check, different reason to run it.
| Dimension | Functional testing | Regression testing |
|---|---|---|
| Checks | A feature against its written requirement | Old behavior against a new code change |
| Tests come from | The requirement, written with the feature | Earlier features, plus one test per fixed bug |
| Triggered by | A new or changed feature | Any change, often to code far from the feature |
| Runs | While the feature is built and before it ships | On each pull request, nightly or before each release |
| A red result means | The feature doesn’t do what was asked yet | Something that already shipped has stopped working |
| Grows by | One feature at a time | Promotion, as functional tests earn a place |
Functional Testing Checks the Requirement
Functional testing compares what software does with what it was supposed to do. Each requirement becomes an input and an expected result, and the test checks the output against it. Only the output counts, so the test stays the same however the code inside is built. For a login form, the requirement might read like this.
- Valid login: A user with the right email and password lands on the dashboard.
- Wrong password: The user stays on the login page and sees “Incorrect email or password.”
- Unknown email: The user sees the same message, so the page never reveals which emails have accounts.
The third line comes from security guidance. The OWASP Authentication Cheat Sheet, from the Open Worldwide Application Security Project (OWASP), says an application must respond with a generic error message whether the password was wrong or the account doesn’t exist. A functional test turns that sentence into something a machine can check.
Regression Testing Checks It Again After a Change
Regression testing re-runs the tests you already have after the code changes, to catch breakage the change didn’t intend. A regression is old behavior that used to work and now doesn’t. The change behind it often sits somewhere else, in a shared helper or a library upgrade.
Most of a regression suite is functional tests that did their first job and stayed on. Regression testing comes in several types, from re-running everything to re-running only the tests near a change. All of them draw on that same pool.
A Login Test, Written Once and Run Again
Three login tests in one folder show both jobs, first on the day they are written and again two sprints later. They use Python’s built-in unittest, so there is nothing to install. Save both files in one folder and run python -m unittest. The handler stands in for a login form post, and in a real app the same checks would run through a browser or an API.
# accounts.py
USERS = {"[email protected]": "correct-horse"}
def log_in(email, password):
"""Handle a login form post. Returns (page, message)."""
if USERS.get(email) == password:
return ("dashboard", "")
return ("login", "Incorrect email or password.")
# test_login.py
import unittest
from accounts import log_in
class LoginTests(unittest.TestCase):
def test_valid_login_reaches_dashboard(self):
self.assertEqual(log_in("[email protected]", "correct-horse"), ("dashboard", ""))
def test_wrong_password_stays_on_login(self):
self.assertEqual(
log_in("[email protected]", "wrong"),
("login", "Incorrect email or password."),
)
def test_unknown_email_gets_same_message(self):
self.assertEqual(
log_in("[email protected]", "wrong"),
("login", "Incorrect email or password."),
)
The run ends with Ran 3 tests and OK. Right now these are functional tests, written from the requirement alongside the feature, and they pass.
Two sprints later a ticket comes in. Users who type [email protected] with a capital letter can’t log in. A developer cleans up the email before the lookup and, while in there, adds a friendlier message for unknown emails. They write a new test for the case fix.
# test_email_case.py, written with the change
import unittest
from accounts import log_in
class EmailCaseTests(unittest.TestCase):
def test_email_ignores_case_and_spaces(self):
self.assertEqual(log_in(" [email protected] ", "correct-horse"), ("dashboard", ""))
# accounts.py after the change
USERS = {"[email protected]": "correct-horse"}
def log_in(email, password):
"""Handle a login form post. Returns (page, message)."""
email = email.strip().lower()
if email not in USERS:
return ("login", "No account uses that email. Sign up?")
if USERS[email] == password:
return ("dashboard", "")
return ("login", "Incorrect email or password.")
The new test passes on its own. Then the whole folder runs, the three login tests from two sprints ago included.
FAIL: test_unknown_email_gets_same_message (test_login.LoginTests.test_unknown_email_gets_same_message)
AssertionError: Tuples differ: ('login', 'No account uses that email. Sign up?') != ('login', 'Incorrect email or password.')
Ran 4 tests in 0.001s
FAILED (failures=1)
The failure is regression testing at work. A test written for the login feature, untouched for two sprints, flagged a change the ticket never asked for. The friendlier message tells anyone typing emails which ones have accounts, which is what the requirement ruled out.
The ticket forgot the security rule. The test written from it remembered.
Put Your Login Flow on a Schedule
Hand the login flow to Pie. It runs again every day, or on the weekdays you pick.
Which Functional Tests Belong in Your Regression Suite?
Every functional test is a candidate, and keeping all of them is how a suite gets slow enough that people stop waiting for it. A red result nobody reads protects nothing.
Five questions decide whether a test gets into the suite at all. Picking which suite tests to run for a given change is a later step called regression test selection. It has less to sort through when the suite only holds tests worth running.
- Would a user notice if this broke? Functional coverage of happy paths and checkout flows is what teams ask us for most. Those earn a slot. A tooltip probably doesn’t.
- Does it cover shared code? A test that passes through code other features use, like authentication or pricing, catches breakage from changes elsewhere.
- Has it caught a bug before? A test with a catch on its record has paid for its slot once, whether it caught a regression or reproduces a reported bug.
- Is the expected result stable? A test that asserts this week’s marketing copy fails whenever the copy changes. Assert the behavior, and leave the wording to a person.
- Does it pass and fail for real reasons? A test that flips without a code change trains the team to re-run instead of read. Martin Fowler calls non-deterministic tests “a virulent infection” that can ruin an entire suite. Fix a flaky test or keep it out until it’s steady.
Apply the five questions to the login example, plus two tests a team might be tempted to add. Four make it in.
| What it checks | Keep it? | Why |
|---|---|---|
| A valid login reaches the dashboard | Yes | Every user hits it, and it runs through shared sign-in code |
| A wrong password keeps the user on the login page | Yes | Users notice, and a security rule sets the message |
| An unknown email gets the same message as a wrong password | Yes | It caught this sprint’s regression |
| The email field ignores capital letters and spaces | After the fix | It reproduces a bug a user reported |
| The login page shows this month’s promo banner | No | The banner copy changes with every campaign |
| The dashboard loads within a fixed two-second wait | Not yet | It fails on a slow runner with no code change |
The four example tests are an easy case because each guards something users rely on. The questions matter most on a feature in its first month, where the requirements keep moving and half the tests will be rewritten. Keep those tests in the feature’s own runs until it settles, then promote the ones that pass the five.
Promote a test for what it guards, once it fails only when the app breaks.
Functional Testing Software for Web and Mobile
The same tool usually runs both jobs, so pick it for the layer you test. A regression suite is only a list of tests and a trigger.
| Layer | Common tools | Runs on | What drives upkeep |
|---|---|---|---|
| Code and API | unittest, pytest, JUnit, Jest, Postman | Every commit | Very little, since the checks are deterministic |
| Web UI | Playwright, Cypress, Selenium | Every pull request, or nightly | Selectors that break when the page changes |
| Mobile UI | Espresso, XCUITest, Appium | Every new build | Repeating each run across OS versions and screen sizes |
The API layer is where I think scripted tests shine. You write deterministic checks once, and they catch regressions as the code moves.
If you are choosing between products, compare functional testing software on who writes the tests and who repairs them after the next UI change. Mobile adds its own wrinkle, because the same flow behaves differently across devices and OS versions, which is where selector-based suites tend to break in mobile regression testing.
Re-Run Your App’s Key Flows With Pie
The login example sat at the code level. The flows your users touch, like sign-up and checkout, need the same two jobs at the screen level. That is where suites get expensive to keep.
Pie is an agentic testing platform that does both jobs, for web apps and for native mobile apps on iOS and Android. Neither job starts with someone writing a script, because Pie is AI-native. The first pass is the functional job, where Pie walks the app on its own, writes tests for what it finds and leaves each expected result for your team to confirm. Every scheduled re-run after that is the regression job.
- Readable steps: Each test is plain steps about what a user does, with no selectors for your team to write or repair.
- Separate schedules: Keep the promoted flows in one suite and a newer feature’s tests in another. Each suite can run on its own Loop schedule, daily for the first and weekly for the second.
- Version per run: When a run looks wrong, check which version of the test it used, so a changed test doesn’t pass for a changed app.
You pick which flows go in the suite. The five questions work the same way on these tests as on the login example.
Promote Tests on Purpose
The login test did its functional job once, on the day the feature shipped. Its regression job came two sprints later, when a friendlier error message started telling visitors which emails have accounts.
The second job is where a test keeps paying, so the decision worth your time is which tests get it. Keep the ones that guard what users rely on and fail only for real reasons. Let a new feature’s tests settle before they join.
Run the five questions on the oldest test in your suite this week, and see whether it still earns its run.
Keep the Tests That Earn Their Run
Name the flows users rely on. Pie re-runs them on your schedule.