liveBook · Manning

Business task

As explained in BDD in Action, Second Edition

A business task is a cohesive user-oriented activity that contributes to a business goal and can be composed into a user journey.

A registration scenario might say, “When a traveler registers for a new account.” That step is useful to a business stakeholder, but automation needs a way to carry it out. A business task names a cohesive piece of the user’s work—such as navigating to registration, entering details, or confirming terms—without making buttons and fields part of the scenario. Several tasks can form a user journey toward a business goal. section 9.3.2

Keep the levels of description distinct:

  • Business rules state the goals and constraints. A business-flow scenario shows the user’s journey through them; each scenario step may require one or more tasks. section 9.3.2
  • Tasks describe what an actor does in domain language. A task can combine smaller tasks or interactions that explain how it is done. section 9.3.3 section 12.4
  • Interactions can use web pages, REST APIs, databases, or other routes. A confirmation email, for example, need not be checked through the UI. section 9.3.3
@When("{actor} registers for a new account")
public void registersForANewAccount(Actor theTraveler) {
    theTraveler.attemptsTo(
            Navigate.toTheFrequentFlyerRegistrationPage(),
            EnterRegistrationDetails.using(travelerDetails),
            Confirms.termsAndConditions()
    );
}

The registration step delegates to three named activities. Its business-facing wording stays separate from the lower-level interactions those activities require. section 9.3.2

In Screenplay, an actor performs tasks to achieve a goal. A reusable task can itself contain other tasks and interactions: logging in can include opening the login page, entering credentials, and selecting Login. This keeps repeated behavior in one place and lets higher-level tests read like the intended business flow. Action classes can also represent business tasks, though UI details embedded in an action may be harder to reuse elsewhere. section 12.1 section 12.9.2

public class Login {
    public static Performable usingCredentials(String username, 
                                               String password) {
      return Task.where("{0} logs in as " + username,
                Navigate.toTheLoginPage(),
                SendKeys.of(username).into("#email"),
                SendKeys.of(password).into("#password"),
                Click.on("#login-button")
      );
    }
  }

The Login task packages navigation and field-level interactions behind one named activity that other tests or tasks can reuse. section 12.9.2

Choose task boundaries around recognizable user activities, not merely around elements that share a page. Keep the scenario’s business intent stable while changing a task’s implementation when the workflow changes—for example, when registration requires another detail or email confirmation. section 9.3.2 section 12.1

How BDD in Action, Second Edition covers it

How deep it goes
Explains task decomposition and delegation, then illustrates reusable Screenplay tasks down to their application interactions.
Examples
Uses account registration, flight search, and login tasks to contrast business-facing activities with their implementation.
What you can do after
Apply it via the Screenplay Pattern to compose reusable tasks that keep acceptance tests focused on business flows.
How it connects
Links business rules, user journeys, automated acceptance tests, actors, Screenplay tasks, and application interactions.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of BDD in Action, Second Edition. The section links point to the parts of the book it draws on.