http://tdd-workshop.uikonf.com
Twitter hashtag #tddberlin
Mobile Central Europe Conference in Warsaw in Feb 2015
book Michael Feathers - Working With Legacy Code
Blog post http://agilewarrior.wordpress.com/2012/10/06/its-not-about-the-unit-tests/
- Specta https://github.com/specta/specta
- Kiwi
- Cedar
- xcpretty - simplify xcodebuild output
- xctool - similar to xcpretty. slower than xcpretty. does not support incremental builds.
- AppCode - less typing
- OCMockito https://github.com/jonreid/OCMockito
- OCMock http://ocmock.org
- KIF https://github.com/kif-framework/KIF
github.com/mobile-warsaw
Pawel Dudek @eldudi
Arrange - set up
Act - do something
Assert - check result
Read book Michael Feathers - Working With Legacy Code
- talks to database, filesystem, network
- edit config files or environment
Isolated
Has to be FAST!
Write test first!
Gets you into the zone
Helps track work
Use your own API before someone else or the rest of the app
If it's hard to test, it's hard to use.
Reduce amount of QA and testing. You will still have bugs.
Work from the outside in
Use examples to clarify requirements
Specta https://github.com/specta/specta
Define specifications
Describe and context block
beforeEach - Arrange and Act
it - Assert
afterEarch - destroy created objects and state from beforeEach
Separation into beforeEach and it
fdescribe
fit
fcontext
it(@"bla", PENDING)
run tests automatically on each change of a file
xcpretty - simplify xcodebuild output to one . per test. builds faster
What does Specta do, that XCTest does not?
Aleksader Zubala @alekzubala
develop in short repeatable cycles
form hypothesis and check them
confidence to refactor
improve code quality
What will move the project forward?
- Write test (object and method might not exist). AppCode makes it easy to create missing files, methods
- Test Fails
Solution does not have to be the best one. Even hardcoding is ok.
Make test pass. Test the test.
Improve solution. Acutally implement.
DRY - don't repeat yourself
Red, Green, Refactor
Baby steps
spend most time on refactoring
easy to identify what goes wrong
move quickly through red, green phases
make cycles short
don't forget refactoring
Add correct index when opening swiping preview.
Return test, value test
When faking, mocking objects you might have to create categories. Only add those to the test target.
describe and context is used to structure the tests
describe -
context -
Arrange
Act
Simulate
Assert
Mock, Spy
Stub, Fake
Maciej Oczko @maciejoczko
File, new - File (not new class) - ClassToTestSpec.m
Add to to test target
type cspec + tab to create starting test code
- test if rightBarButtonItem changes correctly
View lifecycle methods (viewDidLoad etc.) are not called automatically. You have to call them yourself.
Be careful: calling -[UIViewcontroller view] will call loadView, viewDidLoad. But will not call viewWillAppear.
Find inflection point: narrow interface to a set of classes
example here: Singleton PollManager made testing difficult
- break external dependencies with dependency injection (passing parameters e.g. initWith:)
- break internal dependencies with extracting a small method
After that make changes.
extract validation logic to test textfiel validation. lines 116-138
cit is live template (code snippet) that expands. See Settings -> Live templates
alt+enter - create class, create missing methods etc.
alt+cmd+c - create constants from repeated strings
cmd+shift+t - switch from test to implementation class
alt+enter - dow what i need, like create new class