I spent most of today reworking the core logic of @TheMugshotBot and really enjoyed it! This is super exciting because it opens up a lot of new opportunities for upcoming themes and customizations. And ironed out a bunch of bugs.
A big help was commenting out the entire model and TDDing the bulk of the logic. I missed a few things on the first pass, but was able to backfill a feature or two and then wrap it in tests.
I'm all for this "TDDish" approach I've developed over the past few years!
Deep in the weeds...
The code had a bunch of features slapped on here and there. Taking the time document the entire flow (on paper!) and then reimplementing helped consolidate a lot of logic and missed edge cases.
All the more reason to dedicate time to refactoring!
I'm planning on adding some smarter page caching this week before I launch, so don't expect any changes live on the site just yet. But let me know if you'd like to help beta test!
• • •
Missing some Tweet in this thread? You can try to
force a refresh
XCTest tips and tricks that can level up your Swift testing.
🧵👇
1. Use XCTUnwrap instead of force wrapping optionals
Force unwrapping a nil will cause the test suite to completely crash, meaning no output or reporting. XCTUnwrap provides a nice failure message and fails the test.
2. Set continueAfterFailure to false
If you have multiple assertions in a test they might increase in specificity. The first asserts the size of the array and the second assets the first element. You don't want to run the second if the first fails, it's just noise.