Diese Präsentation wurde erfolgreich gemeldet.
Die SlideShare-Präsentation wird heruntergeladen. ×

Automated Testing on iOS

Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Wird geladen in …3
×

Hier ansehen

1 von 26 Anzeige
Anzeige

Weitere Verwandte Inhalte

Diashows für Sie (20)

Anzeige

Ähnlich wie Automated Testing on iOS (20)

Anzeige

Automated Testing on iOS

  1. 1. AUTOMATED TESTING 
 ON IOS
  2. 2. AGENDA Fundamentals of automated tests Different Types of Tests Unit Tests Integration Tests UI Tests Demo
  3. 3. FUNDAMENTALS OF AUTOMATED TESTS
  4. 4. FUNDAMENTALS Write code to specify & verify behavior of application When I attempt to log in
 And the provided password is incorrect
 
 I expect to see an error message What is being tested? How is it being tested? What is the expected 
 result?
  5. 5. FUNDAMENTALS Without tests you: 1. Change code 2. Restart App 3. Set up required state & navigate to part of app you are testing 4. Find out the behavior is still wrong, start over at 1. ⌘+R → 🕐🕑🕒
  6. 6. FUNDAMENTALS An application with good test coverage can be validated almost entirely in a few seconds ⌘+U → ✅ You can even run this on a CI Server!
  7. 7. CONTINOUS INTEGRATION SERVERS JenkinsTravis-CI Circle-CI Run automated tests upon every push to repository - send notifications
 to you and team members when tests break!
  8. 8. SUMMARY When I attempt to log in
 And the provided password is incorrect
 
 I expect to see an error message Tests describe your application’s behavior to other developers 
 and product owners! They allow you to automatically verify 
 correctness of application!
  9. 9. DIFFERENT TYPES OF TESTS
  10. 10. DIFFERENT TYPES OF TESTS Unit Tests - Verify the behavior of one individual unit of work Integration Tests - Test entire features, e.g. login while connecting to a backend server UI Tests - Interact with your application through the regular UI elements, specific form of integration test Which code is broken? Which feature is broken? Can the user interact with UI as expected?
  11. 11. UNIT TESTS
  12. 12. FEATURES OF A UNIT TEST Runs isolated from any other test, sets up its entire environment Only tests a single unit of code - all this code’s dependencies need to be mocked out (details later)
  13. 13. HOW TO WRITE A UNIT TEST Arrange set up the state that the test needs to run - e.g. create the object you want to test Act interact with your code - e.g. call a method on the created object Assert verify the result - e.g. check that the state of the object changed as expected
  14. 14. HOW TO VERIFY UNIT TESTS Return Value you call a function/method and assert on the return value State Change you call a method and assert that the state of the object changed Interaction you call a method and make sure that the object calls another object
  15. 15. HOW TO ISOLATE UNIT TESTS Stubs return predefined results for method calls/properties Mocks are used to verify that a method has been called on a given object Fakes behave similar to the real object but take shortcuts in implementation (complex Stubs)
  16. 16. INTEGRATION TESTS
  17. 17. FEATURES OF AN INTEGRATION TEST Less strict than a Unit Test, can test a larger portion of functionality Is allowed to depend on outside resources, e.g. a database or a web service Useful for testing a feature in its real environment Higher chance of “false positives”
  18. 18. UI TESTING
  19. 19. FEATURES OF AN UI TEST Specific form of integration test that tests your app entirely through the UI Xcode 7 provides support for recording UI tests
  20. 20. SUMMARY
  21. 21. SUMMARY There are two broad categories of automated tests, Unit Tests and Integration Tests Automated tests allow us to verify applications fast and reliably Automated tests inform us about breaking changes to existing features
  22. 22. ADDITIONAL RESOURCES
  23. 23. ADDITIONAL RESOURCES Book by Roy Osherove: The Art of Unit Testing Blog Post: iOS Testing in 2015 iOS Unit Testing Blog Blog Post: Mocking in Swift
  24. 24. LIVE CODING: NUMBER GUESSING GAME
  25. 25. NUMBER GUESSING GAME 1. Computer guesses a number within a specified range 2. You attempt to guess number 3. Computer tells you whether you were correct or whether number was too low or too high 4. You repeat step 2.-4. until you guessed the number successfully

×