Unit Testing
You can write unit tests for Unity using the NUnit framework. This allows you to automate testing and ensure the stability and quality of your project.
To learn more about unit testing in Unity, see the Unity Documentation.
Test types
Unity supports two main test types:
- Edit Mode tests for pure C# logic that run without entering Play Mode.
- Play Mode tests for behavior that requires the Unity runtime.
Buildalon automation currently supports Edit Mode tests. If you need Play Mode coverage, keep tests in a separate workflow step and run them locally or in a dedicated CI job.
Adding Unit Tests to Your Workflow
1. Run Unit Tests
Add this step to your workflow, ideally after Project Validation in your build workflow.
- uses: buildalon/unity-action@v1
name: ${{ matrix.build-target }}-Editor-Tests
with:
build-target: '${{ matrix.build-target }}'
args: '-runTests -batchmode -testPlatform EditMode "${{ github.workspace }}/Logs/EditMode-test-results.xml"'
log-name: 'EditMode-Tests' See the full list of command line options in the Unity Documentation. NOTE: currently only Edit Mode tests are supported in Buildalon automation.
Best practices
- Keep tests small and deterministic.
- Avoid network calls in test code.
- Write tests for build pipelines and serialization changes.
- Store test results as artifacts so the team can review failures.
2. Upload Test Results
Update your upload-artifacts step to include the test results file.
- uses: actions/upload-artifact@v4
...
with:
...
path: '${{ github.workspace }}/Logs/EditMode-test-results.xml' 3. Review Test Results
Your workflow job will fail if any tests fail. To review the test results, download the test results artifact from the job logs.
Related pages
Next Steps
- Triggers: Set up triggers to start workflows automatically.
- Build Unity: Set up automated builds for your Unity project.
- Buildalon Actions: Explore the actions available to use in your workflows.
- Unit Testing: Automate unit testing to ensure stability and quality.
- Deploy to Stores: Add deployment steps to distribute your app to users.
- Dependencies: Learn what to do if your project depends on other private packages or repositories.

