Still here? Cool.
Up until now I've been feverishly adding new units, and any vital special rules those units need (for instance, undead units really do need unstable), but avoiding the less necessary rules like special weapons - like Halbards (I added those last night btw).
I foolishly didn't write unit tests as I was developing and instead tested it by running the app myself and checking the full debug logs I had already added into the app.
Slowly, and surely, checking and debugging anything with this method started to take more and more time. It's also quite error prone, as you can imagine.
Eventually I reached a place where a few things occurred.
- Debugging like this was clearly taking more time than if I just wrote a unit test for the same instance. Starting the app, picking the exact units and formations, all took time vs pressing the UP arrow, and enter to run some unittests.
- There were vast swathes of code, nay, entire plains worth, which I was afraid to touch in case I broke anything. My testing method meant that I couldn't go back and retest everything, I could only test for a specific case or thing which I had just added. Clearly not a good place to be.
I should have known better, I did really, but was attempting to fool myself. No really, I should have known better. WFB is a massive set of rules, all thrown into the same mix and interacting with each other. What did I think was going to happen? That I would construct a massive & intricate spiders web of interconnected code and it would all be fine?
Yesterday I decided it was time to pay the unittest piper.
The unit tests I've written in 3 hours have already picked up some juicy bugs:
- Derpy Mounts: I implemented mount attacks in combat in v0.50. Unittests showed that they were totally broken, the mounts would act as their parent unit and just use their stat line when attacking i.e. Demigryph knight mounts would use their knights statline when attacking. Fixed.
Demigryph's (and other mounts) are a lot better now. Sorry about that.
- The Mounts were receiving supporting attacks. Mounts should not get supporting attacks. Fixed.
If you're reading this and aren't a coder of some sort, unittests might sound like some magical easy band aid. They're perfect for my situation. Once they're covering a lot of the app's code it will mean I can add new code, or edit existing code and if I break anything the tests will throw an error in the relevant test case.
The downside is that they're going to be a metric tonne of work and I won't be adding armies or special rules handling while I'm implementing tests. Still, catching bugs like the above ones make it worth while.