Overview

Chapter 11. Strategies for implementing acceptance tests

The chapter explains that acceptance tests should verify the essential fulfillment of user stories, not every detail of the system. The right level of testing depends on the story itself, the amount of expected change around the interface, and the technology in use. When a requirement is mainly about logic or rules, it is often better to test that logic directly; when the story is about user-facing behavior, end-to-end testing through the real interface may be the best fit.

It then compares several implementation strategies. End-to-end tests are the most natural and representative of real use, but they are often slower and more brittle because they depend on the UI. Crawling under the skin reduces that pain by testing through abstract UI concepts, service layers, or internal APIs instead of concrete widgets. In some cases, tests can go even deeper and exercise internals directly, or use stubs and testing backdoors to isolate irrelevant components, improve speed, or make hard-to-reach behavior observable.

The chapter also shows how technology changes the choice of strategy across different kinds of systems such as libraries, distributed systems, console apps, GUI apps, and web applications. Web and GUI systems often make UI-based testing more complex, while libraries and machine-to-machine interfaces are usually easier to automate. Finally, it offers practical advice for keeping acceptance suites maintainable: organize tests to reduce setup, minimize persistence costs, avoid brittle dependencies, simplify test cases with better abstractions, and manage test data carefully through a single, version-controlled, and preferably generated dataset.

End-to-end test scenario with the test accessing the system through its external interface, knowing nothing about the system’s internals
We often face a trade-off between running the full suite of tests that provide a high level of certainty and running fewer tests that provide less feedback (certainty) but do it faster.
Test operating against an internal API or an abstract UI in addition to or instead of the real UI
Listing 11.2. Examples of different styles of crawling under the system’s skin
Acceptance tests can also access a system’s business logic directly, bypassing any external interface or API.
Testing a system with a less relevant component replaced with a testing-friendly, fast-executing stub
Making use of a testing backdoor in our acceptance tests
Networking is slow compared to direct access to a Java API, which suggests that we should consider implementing most of our acceptance for a “faceless” system against internal APIs and let a smaller subset of tests verify that the networking API processes incoming data correctly and renders the system’s response properly back to the wire.
Application is started from the test
Tests are embedded into the application through a plug-in mechanism.
A Ruby script controlling a Safari web browser on Mac OS X using the SafariWatir library
Tests without side effects can be executed one after another without running the full setup in between each test. Tests with side effects can then be executed as usual, with the setup before each individual test.
Single test client load-balancing test cases between multiple target systems
Multiple test clients executing their subset of tests against their dedicated target system
Multiple test clients load-balancing test cases between multiple target systems
With ordered, dependent tests, we can perform a common setup just once in the beginning of the test suite. However, each test case may have assumptions about the side effects of earlier tests.
Test suite with dependencies between tests has test failures. Without analyzing test logs and wielding psychic powers, it’s impossible to say which of the four failing tests are failing for a legitimate reason and which are failing because a dependent test failed.
A caching context object not only knows how to operate the system into the correct state but also takes a snapshot of the system state after reaching the desired context. The snapshot can be used in later tests using the same caching context to restore the state quickly without redoing the full sequence of steps.

FAQ

What should acceptance tests test in a TDD/ATDD project?Acceptance tests should verify the correct fulfillment of requirements as described by user stories or similar requirements artifacts. They do not need to test everything, but should focus on the essential behavior needed to prove the story has been implemented properly.
Why shouldn’t acceptance tests always go through the UI?Because UI-based tests are often brittle, slower, and more expensive to maintain. If the story is really about business logic or calculations, it is usually better to test that logic directly instead of routing every test through the interface.
When is it a good idea for acceptance tests to go end to end?End-to-end testing makes the most sense when the behavior is naturally expressed through the real user interface, when the system’s full integration matters, or when the story is about a true user workflow such as login redirect behavior or a complete browser-based scenario.
What does “crawling under the skin” mean in acceptance testing?It means testing beneath the UI by using an abstract UI, internal service layer, or other programming interface instead of driving only the visible widgets. This reduces brittleness and can make tests faster and easier to maintain.
What is the difference between crawling under the skin and exercising the internals?Crawling under the skin still tends to work through an application-facing interface, just one that is more abstract than the real UI. Exercising the internals goes further by testing a specific internal part of the business logic directly, without using an external UI or API designed for normal use.
Why would a team stub out irrelevant components in acceptance tests?Teams stub out irrelevant components to improve speed, reduce complexity, or avoid unavailable or expensive dependencies such as databases, third-party services, or file systems. This helps make tests more practical while still preserving enough confidence in the system.
What is a testing backdoor?A testing backdoor is an alternative interface that allows tests to inspect or manipulate the system in ways not intended for normal users. Common examples include directly accessing the database or using a special hook for setting up or verifying system state.
How do technology choices influence acceptance test strategy?Technology affects what is feasible, what is easy, and what is costly. For example, Java applications may support intrusive access through reflection, while native GUI systems may make widget interaction easier but API-level access harder. The technology stack strongly shapes the best testing approach.
What are some special considerations for acceptance testing web applications?Web applications often require testing through the UI because presentation logic, HTTP sessions, JavaScript, and browser compatibility can affect behavior. Depending on the system, teams may choose simulation libraries, real browser control, or under-the-skin approaches behind the web layer.
How can acceptance tests be sped up when they become too slow?Common strategies include splitting tests into groups with and without side effects, cheating on persistence with in-memory databases, distributing tests across multiple machines, minimizing setup, rolling back transactions, and using soft boots instead of full restarts.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


Close
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Test Driven Test Driven ebook for free
Close
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Test Driven Test Driven ebook for free