How do you unit test your mods?

Users who are viewing this thread

guiskj

Knight
I am learning how to mod Bannerlord and so far things are going rather well. I am using existing mods to help me navigate the C# code since documentation is not available yet.

However, one thing that I have not been able to understand is how to correctly write unit tests for Behaviours, Layers, ViewModels, etc. There is too much context to set for any of my classes to be constructed correctly and I don't see a path to leverage dependency injection to allow me to mock dependencies.

So I am reaching out here to see if anyone has solved this issue for their mods.

Thank you.
 
Don't listen to that guy.
The real answer here is that you usually never need to do unit testing when creating mods, that's just overkill. Usually we do unit tests on a very low level, and this is never done at runtime, but rather at compile time (or when submitting if you have a build validation process).

What you should do instead is secure your code with asserts and logs, that are only enabled in Debug for performance reasons.
The reason is that in case the API changes or if you do some massive changes in your code, you should get notified if weird things happen. That's the proper way to code.
 
Upvote 0
Back
Top Bottom