Devlog #6 - Adding Testing To My Particle Simulator
I’ve been working on adding unit testing to my project.
It was important for me to add unit tests for several reasons:
- I have never written unit tests in C++, so it’s a good learning experience
- I genuinely want this project to end up as a polished desktop application, and that’s not really possible without following best practices. Tests are important.
- Parts of my application are already extremely vulnerable to bugs
- It’s easier to catch bugs through unit tests than through actual use of the application
Catch2 as the framework
I chose Catch2 as my framework because it seemed easy to work with and not too verbose.
Current sensitive parts of the application
Position, Velocity, and Force are all independent wrappers around Vec2<float>. It is extremely important to me that these have proper arithmetic, but are not implicitly convertible, since that is almost definitely not intended behavior.
This is why I wrote almost 200 lines of code’s worth of unit tests to make sure that the typing system is strong and acts the way I want it to.
Catching bugs easily through unit testing
While a user will most likely eventually stumble upon any bug worth fixing, I don’t really have any users yet! I would like to ship an app that isn’t obviously broken, and to do that, I need unit tests that stress the logic of my program to make sure it can survive users messing with it.
Current progress on writing tests
I’ve written fairly extensive tests to enforce the Vec2<float> variants type system, and to enforce particles working and ticking correctly and interacting with modules correctly. I still have many more tests to write, and I expect to spend the next couple of hours doing that. Thank you for reading!
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.