Why Testing More UI States Improves Quality
- State changes per min
- changes/min
- Result
- Time on page
- 5 min
- You entered
- Data items
- 100 items
- You entered
Testing more UI states improves quality because it catches defects that only appear under specific conditions—empty data, slow networks, unusual screen sizes, or user permissions—before real users hit them. By systematically exercising a wider range of states, you reduce the chance of runtime errors, broken layouts, and confusing interactions, leading to a more robust and trustworthy product.
Formula
The number of possible UI states for a page with d independent binary features (e.g., logged in/out, data loaded/empty, network online/offline) is 2^d. The formula for the headline output is:
Possible states = 2d
Where:
- d = number of independent binary conditions (unit: count)
This exponential growth is why testing every combination is impractical—but it also shows how quickly untested states accumulate.
Worked Example
Using the default values from the calculator: d = 100 data items.
Possible states = 2100 = 1.2676506 × 1030 states.
That is 1.267 billion trillion trillion states—far more than any test suite can cover. The point is not to test all of them, but to prioritize the ones that matter most.
Background: What Are UI States?
A UI state is any distinct condition that changes what the user sees or can do. Common examples include:
- Loading – data is being fetched
- Empty – no data to display
- Error – a request failed
- Partial – some data loaded, some missing
- Authenticated vs. guest – different permissions
- Responsive breakpoints – mobile, tablet, desktop
- Network offline/online – connectivity changes
Each state can have sub-states: an empty state might have a “create new� button or a “learn more� link. Testing more states means verifying that each of these conditions renders correctly, behaves as expected, and transitions smoothly to other states.
How More Testing Catches Real Defects
Defects often hide in untested states. For example:
- A dashboard shows a chart that crashes when the dataset is empty (division by zero).
- A form’s submit button is disabled when the user is offline, but no message explains why.
- A text input overflows its container on a 320px-wide screen, making the “Submit� button unreachable.
- A user with “view-only� permissions sees an edit button that throws a 403 error when clicked.
By deliberately testing these states, you find and fix such issues before release. This is especially important for error handling and edge cases, which are often left untested because they are “unlikely� or “hard to simulate.�
How to Choose Which States to Test
You cannot test every combination (as the formula shows), so prioritize based on risk and frequency:
- Identify critical user journeys – the paths users take most often (e.g., login, checkout, search).
- List the states each journey can enter – loading, empty, error, success, etc.
- Rank by impact – a broken checkout is worse than a broken “about us� page.
- Use real usage data – if analytics show 30% of users are on mobile, test mobile breakpoints thoroughly.
- Automate what you can – snapshot testing and component testing can cover many states cheaply.
Remember: a state that is rarely seen but catastrophic (e.g., a bank transfer error) deserves more attention than a common but harmless one.
Common Problems and Misconceptions
Misconception: “If it works on my machine, it works everywhere.� That is only true if your machine matches every possible state—which it doesn’t.
Problem: Over-testing trivial states. Spending hours testing a “tooltip on hover� state while ignoring the “payment failed� state is a waste of effort.
Problem: Forgetting state transitions. It’s not enough to test that the loading spinner appears; you must also test that it disappears when data arrives, and that the error state replaces it correctly.
Problem: Not using realistic data. Testing with perfect, well-formed data misses issues that arise with long strings, special characters, or missing fields.
Comparison: Manual vs. Automated Testing
Manual testing is flexible and can catch visual nuances, but it is slow and inconsistent. Automated testing (unit, integration, and end-to-end) can run thousands of state checks quickly, but it requires upfront investment and maintenance. The best approach is a mix:
- Unit tests for pure logic (e.g., formatting functions).
- Component tests for individual UI elements in various states (e.g., a button disabled, loading, error).
- End-to-end tests for critical user journeys across multiple states.
- Manual exploratory testing for edge cases and visual regression.
Automated tests are especially valuable for regression—ensuring that a fix for one state doesn’t break another.
Costs and Limits
Testing more states costs time and money. Each additional state requires writing and maintaining test cases, which can slow down development. There is also a limit to what automated tests can catch: visual glitches, subtle animation issues, and accessibility problems often need human eyes.
Moreover, some states are hard to simulate (e.g., a server that responds after 10 seconds, or a device with a very specific screen size). In those cases, you might rely on monitoring and error reporting in production to catch issues after release.
Finally, testing cannot guarantee zero defects—it only reduces the probability of certain defects. The goal is to test enough to achieve the quality level your users expect, not to test everything.
Frequently Asked Questions
Q: How many UI states should I test?
A: There is no fixed number. Prioritize states that are common, critical, or risky. Start with the main user journeys and their error/empty/loading states, then expand to less common but high-impact scenarios.
Q: What is the most commonly missed UI state?
A: The empty state is often overlooked because developers test with data already present. But empty states are common—first-time users, cleared search results, or unfiltered lists—and a broken empty state can make the app feel broken.
Q: Can automated testing replace manual testing?
A: No. Automated tests are excellent for repetitive checks and regression, but they cannot judge visual design, animation smoothness, or overall user experience. A combination is best.
Q: How do I simulate network errors or slow connections?
A: Browser DevTools can throttle network speed and simulate offline mode. For more control, use tools like Charles Proxy or Fiddler to intercept requests and return custom responses.
Q: Is it worth testing states that are extremely unlikely to occur?
A: If the state is truly impossible (e.g., a negative number of items), you can ignore it. But if it’s merely rare and has high impact (e.g., a server timeout during payment), it’s worth testing.
Q: What is the biggest mistake in UI state testing?
A: Testing only the “happy path� (everything works perfectly) and ignoring error, empty, and edge states. The happy path is the least likely to fail, so it gives a false sense of confidence.
Related
Formula used
in t | Time on page | min | 5 | 0 in d | Data items | items | 100 | 0 out states | Possible states | states | 2^d | 0 out state_changes | State changes per min | changes/min | states / t | 2
Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.