Blog / What Is UI Testing? How It Differs From End-to-End Testing
Guide

What Is UI Testing? How It Differs From End-to-End Testing

UI testing checks one screen's controls, states and errors with the backend stubbed. See a sign-up screen tested two ways in Playwright, and what each catches.

UI testing checks that one screen of an app behaves as it should (its controls, states, error messages and input rules), usually with the rest of the stack held still so only the screen can fail.

The trouble is the word. A UI test and an end-to-end test click through the same screens with the same tools, and they often share a folder. They answer different questions. One sign-up screen, tested both ways in Playwright and broken twice, shows which test each bug belongs to.

What you’ll learn

  • What a UI test checks, and the line that separates it from an end-to-end test
  • Three stubbed UI tests and one end-to-end test for a sign-up screen, in Playwright code we ran
  • Two deliberate breaks, and which level caught each one
  • Which bugs are the cheaper catch at each level, and the tools for web, Android and iOS

What Is UI Testing?

UI testing is the practice of checking an application’s interface the way a user meets it. You open a screen, interact with it, and assert on what it shows. A UI test asks whether that one screen behaves. Does the button lock while a request is in flight? Does the error appear under the field it’s about? Does the screen keep what the user typed when the server fails?

The term gets used loosely. Android’s testing guide says UI tests “launch an app (or part of it), then simulate user interactions, and finally check that the app reacted appropriately,” and that they range “from verifying the behavior of a small component to a large navigation test that traverses a whole user flow.” With a range that wide, the tool can’t be the line. What the test fakes can.

The same guide suggests replacing the data layer with an in-memory fake that provides “fake, deterministic data to the test,” swapped in through dependency injection. In the narrow sense, a UI test does exactly that. The screen is real, and everything behind it answers on cue. It works from outside the code, the way black box testing does, but it also reaches behind the screen to decide what the screen hears back.

In one line

A UI test asks whether one screen behaves with everything behind it held still. An end-to-end test asks whether a journey works across the whole stack.

Two other kinds of check also go by the name. Whether a screen looks right across sizes and releases is the job of visual regression testing, which compares screenshots with a baseline. Whether people using screen readers or keyboards can use it is the job of accessibility testing.

UI Testing vs End-to-End Testing

Both kinds drive a real screen with the same tools, so the difference sits in what’s real behind the screen and what a failure tells you. End-to-end testing runs a journey through every layer, the UI, API, database and anything else the journey touches, such as email, and fails when any of them breaks the journey. A UI test stubs the server and its data, so when it fails, the screen is the suspect.

DimensionUI testEnd-to-end test
Question it answersDoes this screen behave?Does this journey work?
What’s realThe screen, in a browser or on a deviceThe UI, API, database and anything else the journey touches
What’s stubbedThe API and data behind the screenNothing, or only services you don’t own
States it can reachAny, on demand: slow, failing or conflicting responsesThe ones the real system produces
A failure points atThe screen’s codeAnywhere along the journey
How many you wantOne per state a user can seeOne per journey you can’t afford to break

Write the state checks as UI tests, and save end-to-end tests for the journeys your business can’t lose.

A Sign-Up Screen, Tested at Both Levels

The screen is a sign-up form with an Email field, a Password field and a Sign up button. A small Node server behind it creates the account and writes a verification email to an outbox. A test-only endpoint returns the last message written for an address, so a test can read it. We ran both specs below with Playwright 1.65.1 on Chromium and Node 22.21.0.

The UI tests stub the sign-up API with page.route. With a route fulfilled this way, as Playwright’s docs on mocking APIs put it, “No requests to the API will be made.” Each test picks the server’s answer: a taken email, a slow response, a failure.

// signup-ui.spec.ts: the sign-up screen alone, with the API stubbed
import { test, expect } from '@playwright/test';

test.beforeEach(async ({ page }) => {
  await page.goto('/signup');
  await page.getByLabel('Email').fill('[email protected]');
  await page.getByLabel('Password').fill('correct-horse-1');
});

test('taken email: error under the field, button usable again', async ({ page }) => {
  await page.route('**/api/signup', (route) => route.fulfill({ status: 409, body: '{"error":"email_taken"}' }));
  await page.getByRole('button', { name: 'Sign up' }).click();
  await expect(page.locator('#email-error')).toHaveText('This email already has an account. Sign in instead?');
  await expect(page.getByRole('button', { name: 'Sign up' })).toBeEnabled();
});

test('slow server: button locked while the request is in flight', async ({ page }) => {
  let release!: () => void;
  const held = new Promise<void>((resolve) => (release = resolve));
  await page.route('**/api/signup', async (route) => { await held; await route.fulfill({ status: 201, body: '{}' }); });
  await page.getByRole('button', { name: 'Sign up' }).click();
  await expect(page.getByRole('button', { name: 'Signing up...' })).toBeDisabled();
  release();
  await expect(page.getByRole('heading', { name: 'Confirm your address' })).toBeVisible();
});

test('server error: message shown, typed email kept', async ({ page }) => {
  await page.route('**/api/signup', (route) => route.fulfill({ status: 500 }));
  await page.getByRole('button', { name: 'Sign up' }).click();
  await expect(page.locator('#form-error')).toHaveText('Something went wrong. Try again.');
  await expect(page.getByLabel('Email')).toHaveValue('[email protected]');
});

Two of those three states show up against a real backend only on a bad day. Making a server slow or failing on purpose takes setup, while a stub does it in one line.

The end-to-end test stubs nothing. It signs up a fresh address and reads the verification message through the test-only endpoint. Then it opens the link and checks that the account is verified.

// signup-e2e.spec.ts: the real server and the link it wrote, nothing stubbed
import { test, expect } from '@playwright/test';

test('new user signs up and verifies their email', async ({ page, request }) => {
  const email = `new-${Date.now()}@example.com`;
  await page.goto('/signup');
  await page.getByLabel('Email').fill(email);
  await page.getByLabel('Password').fill('correct-horse-1');
  await page.getByRole('button', { name: 'Sign up' }).click();
  await expect(page.getByRole('heading', { name: 'Confirm your address' })).toBeVisible();

  const { body } = await (await request.get(`/test/outbox?to=${encodeURIComponent(email)}`)).json();
  const link = body.match(/https?:\/\/\S+/)[0];
  await page.goto(link);
  await expect(page.getByRole('heading', { name: 'Email verified' })).toBeVisible();
});

All four passed on the clean build. Then we broke the app twice, once behind the screen and once on it, and ran the same four tests against each break.

BreakUI tests (3)End-to-end test (1)
The server’s verification link points at /verfy instead of /verify3 passedFailed, no “Email verified” heading
The screen never unlocks the button after a failed request2 passed, the taken-email test failedPassed

Each break failed exactly one level. The link typo lives behind the screen, where no stub can see it. The locked button only appears after a failed request, and the happy-path journey never makes one. A user whose email was already taken would have been stuck on a button reading Signing up… with nothing to press. A suite with only one of the two levels ships one of these bugs.

Which Bugs Each Test Catches Cheaper

Cheaper means less time to write, run and diagnose. UI tests need no test data, no inbox and no deployed backend. An end-to-end test costs more every time it runs, and it’s the only one of the two that proves the parts agree.

BugCheaper catchWhy
Error shown under the wrong field, or with the wrong textUI testStub the error response once and assert on the screen
Button stays locked after a failed requestUI testA real server rarely fails on cue
Double submit while the request is slowUI testA held route makes “slow” happen every run
Typed input lost after a server errorUI testA stubbed 500 costs one line
No message when an invalid email loses focusUI testNo request involved, only the screen’s input rule
Verification link points at the wrong pathEnd-to-end testOnly the real email carries the real link
Account created, but the session never startsEnd-to-end testNeeds the real API and the real cookie
Screen and API disagree on a field nameEnd-to-end testA stub encodes your assumption about the API, so it agrees with your bug

End-to-end tests earn their cost on journeys. Spend one on a state and you pay for a full stack to learn that a button didn’t unlock. Stubbing also takes network timing out of the state checks, and timing is one common source of flaky tests. The journeys carry the integration risk instead.

Which Tools Run Automated UI Tests?

Most test automation tools can run both levels. The split lives in how you write the test, mostly in whether you stub the server the screen talks to.

PlatformCommon toolsHow the backend gets stubbed
WebPlaywright, Cypress, Seleniumpage.route in Playwright, cy.intercept in Cypress, request and response handlers through WebDriver BiDi in Selenium
Web componentsTesting Library, Playwright and Cypress component testingThe component renders alone, with props instead of a backend
AndroidEspresso, Compose testing APIsA fake data layer injected through dependency injection
iOSXCUITestA fake backend wired into the app’s own test setup

Both Playwright and Cypress stub the network well, so the Playwright vs Cypress choice turns on other things, such as the languages your team writes and how you run tests in parallel. When one screen’s checks shrink to a single widget, a component test is the smaller tool for the job.

On iOS, XCUITest drives the app from outside its code, so any fake backend has to be wired into the app’s own test setup. On phones the split holds, and mobile app automated testing adds devices and OS versions to every decision.

When the markup changes, UI tests break on how they find elements. Self-healing test automation handles that in one of two ways. Some tools swap a broken locator for its likeliest match. Other AI testing tools, Pie among them, look for each element on the screen first.

Pie’s Self-Healing Tests Read the Screen

The specs above find most elements by label and role, which survives more change than a CSS selector. The two error checks lean on element ids. Both break the moment somebody rewords a label or renames an id. The end-to-end spec crosses the most screens, so it has the most labels to break.

We built Pie to test from the screen. Our agentic testing platform runs the journeys on your app with nothing stubbed. Your stubbed state tests stay in your repo, next to the screen’s code.

  • iOS and Android apps: Pie’s tests are vision-only. They find the Sign up button on the screen as rendered, with no locator behind it.
  • Web apps: Pie’s tests are vision-first, starting from the page as a user sees it.
  • On every run: Pie’s self-healing tests re-read the screen each time they run, so they’re built to survive redesigns. Your team doesn’t write or maintain selectors for Pie’s tests.
Pie's step viewer: a login test's steps beside Portion.ly, as it loads
Pie’s step viewer: a login test’s steps beside Portion.ly, as it loads.

Test the Screen, Then the Journey

The sign-up screen needed both tests, and the two breaks proved it, since each test caught only its own break. Open the screen your users hit first and list the states a user can see on it: empty, invalid, waiting, failed, taken and done. Write a stubbed UI test for each, then keep one end-to-end test that walks the journey through the real stack.

The journeys cost the most to run and keep current. Hand those to Pie, which re-reads the screen on every run.

Keep the State Tests, Add the Journeys

Name the journeys you can't lose. Pie runs them in web, iOS and Android apps.

Frequently Asked Questions

UI testing checks that an app's interface behaves as intended. A UI test opens a screen, interacts with its controls and asserts on what the screen shows, such as an error message, a disabled button or a kept value. Automated UI tests often stub the backend so results stay predictable.
A UI test checks whether one screen behaves, with the API and data behind it stubbed, so a failure points at the screen. An end-to-end test runs a whole journey through the real stack, including the database and anything else the journey touches, such as email, and fails when any part breaks the journey.
For screens with states a user can hit, such as a slow response or a failed request, yes. A stubbed test reaches those states on demand and runs without test data or a deployed backend. It pays off less on screens that change every week, where assertions churn.
On the web, Playwright, Cypress and Selenium are the common choices, with Testing Library for single components. Android teams use Espresso and the Compose testing APIs, and iOS teams use XCUITest. The tool matters less than whether it lets you stub what sits behind the screen.
API testing sends requests straight to the backend and checks the responses, with no screen involved. UI testing drives the screen and checks what the user sees. A bug in how the screen handles an API response, like an error shown under the wrong field, needs a UI test.
UI stands for user interface, the part of an app a person sees and touches, such as screens, buttons, forms and messages. UI testing checks that part. It differs from testing the code or services behind the interface, which unit, integration and API tests cover.
Android teams write UI tests with Espresso or the Compose testing APIs, and Android's guide suggests an in-memory fake of the data layer, swapped in through dependency injection. iOS teams use XCUITest, which runs outside the app's code, so any fake backend lives in the app's own test setup.
Your stubbed UI tests stay in your repo and keep checking each screen's states. Pie runs the journeys on your running app, on the web, iOS and Android. Its self-healing tests re-read the screen every run, so your team doesn't write or maintain selectors for them.
Dhaval Shreyas
Dhaval Shreyas
CEO & Co-founder at Pie

13 years building mobile infrastructure at Square, Facebook, and Instacart. Now building the QA platform he wished existed the whole time. LinkedIn →