Unit Tests - AlexisBliesener/Bewitched GitHub Wiki
Unit Testing Guidelines
This document explains how we structure and write unit tests for Bewitched using the Unity Test Framework (UTF). Please follow these conventions so our tests remain clean, consistent, and easy to maintain.
Test Location
- All test scripts are located in: Scripts > Tests
- Keeping tests in one folder ensures organization and makes them easy to find.
Naming Conventions
Test Script Naming
- Each test script should match the name of the class it is testing, with 'Tests' appended.
- Example:
- Script: PlayerController.cs
- Tests: PlayerControllerTests.cs
- This helps us quickly see which script the tests belong to.
- Example:
Test Function Naming
- Each test method should follow this pattern: FunctionName_ExpectedBehavior
- Example:
- AddHealth_CapsAtMax → Tests that AddHealth caps health at the maximum value.
- This format makes it immediately clear what function is being tested and what the expected outcome is.
- Example:
Writing Tests
Follow the AAA pattern:
- Arrange → Set up the state, objects, and inputs for the test.
- Act → Call the function you want to test.
- Assert → Verify the output or side effects are correct.
References
Here are some quick video tutorials we recommend before writing your first test: