- Simple app (created by someone else) that shows a list of tallest towers and their details.
- This forked project originally included both unit and UI tests.
- My goal is simply to practise writing tests, I deleted them so I can write from scratch.
- To run all tests locally, choose "Test" from the "Product" menu or press ⌘U.
- XCode 14.1
- macOS Ventura 13.0.1
- Run the app in a simulator, does it work? (Yes, ran in iPhone 14 Pro, iOS 16.1)
- Write down what each unit and UI test does (in plain English)
- Delete the original unit and UI tests (apart from the import statements) - Ouch!
- Re-implement those tests (without looking)
- Compare your answers to the original solutions
Reimplement these tests:
Unit Tests
- Create a test case called 'TowerInstanceTests'
- Create a a setup function. It should create a test variable to store a dummy tower, use the implicit unwrapped optional.
- 'testLocationShouldBeCreatedFromLatitudeAndLongitudeProperties' - check you can access the location's latitude and longitude for a Tower instance. Pay attention to accuracy.
- 'testCityAndCountryShouldConcatenateCityAndCountry' - self-evident.
- 'testFormattedHeightIncludesUnits' - self-evident.
- Create a test case called 'TowerStaticTests'
- 'testTallestTowersShouldNotBeEmpty' - self-evident.
- Run unit tests
Mission accomplished, I did it and took away 4-5 learning points from this!
UI Tests
- Create a test case called 'TallestTowersUITests'
- Set up the app to launch
- Test 0 - Check that the title on app home screen is 'Tallest Towers'
- Test 1 - Check that 'Burj Khalifa' exists in the list and tap on it
- Test 2 - Check that 'Shanghai Tower' exists in the list and tap on it
- Test 3 - Tap on a tower entry and check the details match that tower
- (BONUS) - For tests 1 and 2, check the backlink 'Tallest Towers' exists
See logged issues in this repo. One non-technical lesson. Next time, don't practice with a repo that is more than a year old.