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.
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.
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.
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.