Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

3. How to Write a Unit Test > Seeing Expected Results

Seeing Expected Results

Now that I can call my method with input under my control, I need to inspect what that method does and ensure that the results are consistent with the app’s requirements. I know that the result of running the method should be to change the text of a label, so I need a way to discover what happens to that label. I can’t pass that label in as a parameter to the method, because the API contract for the UITextFieldDelegate method doesn’t allow for it. The object that provides my temperature conversion method will need a property for the label so that the method can find it.

As with the input text field, it looks like the only part of the label this method will need to deal with is its text property, so it seems I can reuse the FakeTextContainer class I’ve already built. The test case now looks like this:


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint