-
Notifications
You must be signed in to change notification settings - Fork 9
Dev Docs: Unit Testing
Most of MoreMcmeta's classes are fully unit tested. As much as possible, code is written to be fairly independent of Minecraft's code to improve testability and minimize changes between Minecraft versions. Testing includes exception testing and null conditions.
Some "unit tests" are closer to integration tests because the component is not useful by itself or contains little logic, such as the texture components.
It is not realistic to try and unit test 100% of MoreMcmeta's code since it uses Minecraft classes that are not easily testable, like the texture atlas. However, there are a few ways to improve code coverage in a modding environment.
- Dependency injection. Most units accept other units in their constructor. Interfaces are often helpful.
- Composition over inheritance. That's not to say inheritance is always bad, but composition allows you to mock units and reason about code more easily.
-
Adapters. The
adapterspackage contains code that wraps difficult-to-test Minecraft code in an interface that MoreMcmeta needs. - Separation of concerns. You can often isolate difficult-to-test code from testable code.
-
Render system calls.
RenderSystem.recordRenderCall()is useful to "ignore" code that must be on the render thread and will crash in tests.
Please report errors or suggest improvements to this wiki using the documentation template on the issue tracker.
User Docs are written for regular Minecraft players and resource pack authors.
- User Docs: Animation Format
- User Docs: Emissive Format
- User Docs: Install Plugins
- User Docs: Troubleshooting
Plugin Docs are written for plugin developers.
- Plugin Docs: Overview
- Plugin Docs: Maven
- Plugin Docs: Plugin Registration
- Plugin Docs: Parser Plugins
- Plugin Docs: Texture Plugins
Dev Docs are written for MoreMcmeta developers.