Use mocks and stubs in your tests to isolate the behavior of the code youre

Use mocks and stubs in your tests to isolate the

This preview shows page 300 - 305 out of 517 pages.

Use mocks and stubs in your tests to isolate the behavior of the code you’re testing from the behavior of other classes or methods on which it depends. Various code coverage metrics help you determine which parts of your code need more testing. For the Plan and Document lifecycle, you use some of the same concepts in a quite different order and even with different people: The program manager assigns programming tasks based on the SRS, so unit testing starts after coding. Quality-Assurance ( QA ) testers take over from the developers to perform the higher level tests. Top-down , Bottom-up , and Sandwich are options on how to combine the resulting code to perform integration testing . The testing plan and results are documented, such as by following IEEE Standard 829-2008. After integration testing, the QA team performs a systems test before releasing it to the customer. Testing stops when a specified level of coverage is reached, such as “95% statement coverage.”
Image of page 300
An alternative to testing, used for small critical software, is formal methods . They use formal specifications of correct program behavior that are automatically verified by theorem provers or by exhaustive state search, both of which can go beyond what conventional testing can do. Their approaches to testing are some of the starkest differences between Agile and Plan-and-Document lifecycles: when test writing starts, the order that levels of tests are written, and even who does the testing.
Image of page 301
8.1 Background: A RESTful API and a Ruby Gem Chapter 1 introduced the Agile lifecycle and distinguished two aspects of software assurance: validation (“Did you build the right thing?”) and verification (“Did you build the thing right?”). In this chapter, we focus on verification—building the thing right—via software testing as part of the Agile lifecycle. Figure 8.1 highlights the portion of the Agile lifecycle covered in this chapter. Although testing is only one technique used for verification, we focus on it because its role is often misunderstood, and as a result it doesn’t get as much attention as other parts of the software lifecycle. In addition, as we will see, approaching software construction from a test-centric perspective often improves the software’s readability and maintainability. In other words, testable code tends to be good code, and vice versa.
Image of page 302
Figure 8.1: The Agile software lifecycle and its relationship to the chapters in this book. This chapter emphasizes unit testing as part of Test-Driven Development. In Chapter 7 we began working on a new feature for RottenPotatoes to enable information about a movie to be imported automatically from The Open Movie Database , or TMDb for short. In this chapter, we’ll develop the necessary methods to complete this feature. Method or function? Following the terminology of OOP (object-oriented programming), we use method to mean a named piece of code
Image of page 303
that implements a behavior associated with a class, whether it’s more like a function that returns a value or more like a procedure that causes side effects. Additional historical terms for such a piece of code include
Image of page 304
Image of page 305

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