Generating test cases with SwiftCheck
updated 12 months ago; latest suggestion 11 months ago
Writing unit tests is one of the most important parts of producing software. Tests prove correctness of your program, they help catch bugs early in development cycle, they guard against regressions, and may even act as documentation.
Having such high expectations, it is very important that your unit tests actually meet them and that your test cases cover more than just one happy path. Although coming up with various test cases, especially with erroneous ones, might be hard, there is a solution for that problem.
In my talk, I will introduce you to an alternative approach of property-based testing using SwiftCheck and the idea of having tests find edge cases for you.
- Traditional ways of writing test cases
- Describing the problem
- Introduction to SwiftCheck
- Idea of property-based testing
- Brief history of SwiftCheck
- Fundamental principles and features of SwiftCheck
- Using SwiftCheck
- Testing pure functions and algorithms
- Testing stateful code
- Extending SwiftCheck
- Supporting custom types
- Composing generators
- Custom generators
- Replaying tests
- Integrating with Quick and Nimble
Thanks for the suggestion! Yes, comparison to standard ways of testing and real-life examples are part of section 4. In addition, I would like to describe how to take advantage of both worlds to make tests reliable and more helpful.
An interesting topic, I would love to learn how to improve testing. It would be awesome to put a special emphasis on highlighting the differences between a standard way of writing unit tests and using SwiftCheck with some examples. That will help to convince business people not only to do unit tests in projects but also to do it right.
Thanks for the suggestions! I updated the proposal accordingly.
I once saw short presentation about SwiftCheck. It's not that kind of framework that you install and are ready to use, some introduction is need. So I think it's interesting to hear about it more and section 3 from agenda is a good idea!
SwiftCheck is a great tool. I'm looking forward to hearing more advanced topics. I hope you could present more than one example of custom generators.
Sounds interesting! I would skip the overview of "traditional" unit tests and go straight to the problems. I also hope you will say more on how test data generation can be implemented for custom types in section 4.3.