7. #7SUnitTest
Unit Tests
Prove correctness of different aspects of the
public interface.
• Prove instead of intuition
• Define contract and assumptions
• Document the code
• Easier refactoring or change
Reusable code = code + tests
9. #7SUnitTest
Use Unit Testing
Incrementally
You don’t have to write every unit test
Start with the classes that take care of the
logic
• If mixed apply SOLID
The easier entry point are bugs
14. #7SUnitTest
Good & Bad News
Most already available in Xcode / not doubles
Projects are created with
• test target
• a crappy example
⌘+U is your friend
Behaviors provide Pavlov reinforcement
XCTest is THE tool for the rest you are on your own
37. #7SUnitTest
Follow the rules
Test your code only
Only a level of abstraction
Only public methods
Only one assertion per test
Tests are independent of sequence or state