Adding a new feature for a SaaS app normally means you specify a UI for the

Adding a new feature for a saas app normally means

This preview shows page 280 - 282 out of 517 pages.

Adding a new feature for a SaaS app normally means you specify a UI for the feature, write new step definitions, and perhaps even write new methods before Cucumber can successfully color steps green. Usually, you’d write and complete scenarios for the happy path(s) first; we began with the sad path only because it allowed us to better illustrate some Cucumber features. The Background keyword can be used to DRY out common steps across related scenarios in a single feature file. Usually, system-level tests such as Cucumber scenarios shouldn’t “cheat” by hard-wiring fake behavior in methods. BDD and Cucumber are about behavior, not implementation, so we would instead use other techniques such as TDD (which the next chapter describes) to write the actual methods to make all scenarios pass. Self-Check 7.8.1. True or False: You need to implement all the code being tested before Cucumber will say that the test passes. False. A sad path can pass without having the code written need to make a happy path pass. 7.9 Explicit vs. Implicit and Imperative vs. Declarative Scenarios Now that we have seen user stories and Cucumber in action, we are ready to cover two important testing topics that involve contrasting perspectives. The first is explicit versus implicit requirements. A large part of the formal specification in plan-and- document is requirements, which in BDD are user stories developed by the stakeholders. Using the terminology from Chapter 1 , they typically correspond to acceptance tests. Implicit requirements are the logical consequence of explicit requirements, and typically correspond to what Chapter 1 calls integration tests. An example of an implicit requirement in RottenPotatoes might be that by default movies should be listed in chronological order by release date. The good news is that you can use Cucumber to kill two birds with one stone—create acceptance tests and integration tests—if you write user stories for both explicit and implicit requirements. (The next chapter shows how to use another tool for unit testing.) The second contrasting perspective is imperative versus declarative scenarios. The example scenario in Figure 7.5 above is imperative, in that you are specifying a logical sequence of user actions: filling in a form, clicking on buttons, and so on. Imperative scenarios tend to have complicated When statements with lots of And steps. While such scenarios are useful in ensuring that the details of the UI match the
Image of page 280
customer’s expectations, it quickly becomes tedious and non-DRY to write most scenarios this way. To see why, suppose we want to write a feature that specifies that movies should appear in alphabetical order on the list of movies page. For example, “Zorro” should appear after “Apocalypse Now”, even if “Zorro” was added first. It would be the height of tedium to express this scenario naively, because it mostly repeats lines from our existing “add movie” scenario—not very DRY: 1 Feature: movies should appear in alphabetical order, not added order 2 3 Scenario: view
Image of page 281
Image of page 282

You've reached the end of your free preview.

Want to read all 517 pages?

  • Spring '19
  • Dr.Marcos

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes
A+ icon
Ask Expert Tutors