This repository shows a few C# tests that use the page object model and AltTester to test the Unity endless runner sample: Asset store unity - endless runner smaple
The TestAlttrashCSharp project containes the game build for Standalone Windows or MacOS platform. The TestAlttrashCSharp.csproj has specified TargetFramework: netcoreapp3.1. This means that need to install the corresponding .NET runtime in order to be able to run the tests.
-
Install the necessary .NET runtime version
-
Create a folder
App
-
on MacOS/Linux Create a folder
TrashCatMac
underApp
. The app is provided at TrashCatMacOS and needs to be included unzipped under the App/TrashCatMac/ folder.on Windows Create a folder
TrashCatWindows
underApp
. The app is provided at TrashCatWindows and needs to be included unzipped under the App/TrashCatWindows/ folder.
The tests are meant to be run on an Windows or MacOS device.
To start the tests, depending of your OS run:
- on MacOS/Linux
./start_tests_Mac.sh
- on Windows
./start_tests_Windows.sh
This script will:
- start the app on your device
- run the tests
- stop the app after the tests are done
You can view a video of how to run the tests on MAC OS by clicking on the following image:
This project already has the AltDriver inside (version 1.8.0), but otherwise would require to add AltTester Driver package in order to work.
Run tests manually (with dotnet CLI)
- Check the dotnet SDK and runtime versions which are installed
dotnet --info
-
Launch game from
App\TrashCatWindows\TrashCat.exe
-
Move to
TestAlttrashCSharp
and execute all tests (mention the output folder)
dotnet test -- NUnit.TestOutputXml = "TestAlttrashCSharp" --results-directory TestResults
! Make sure to have the Alttester Desktop App closed, otherwise the test won't be able to connect to proper port.
dotnet test --filter <test_class_name>
dotnet test --filter <test_class_name>.<test_name>
dotnet test --results-directory TestResults --filter <test_class_name>.<test_name>
Using Allure
Read Setup Allure as pre-requisite.
allure_run_tests_generate_report.sh
-
Launch game from
App\TrashCatWindows\TrashCat.exe
-
Move to
TestAlttrashCSharp
-
Execute all tests and generate output specific for NUnit Allure adapter
dotnet test -- NUnit.TestOutputXml = "TestAlttrashCSharp" --results-directory allure-results
- Generate test results report
allure serve allure-results
After generating allure-report, when we need to save everything into one html file (to share it): install an external package which builds allure generated folder into one html file.
Requirements: Python 3.6+
pip install allure-combine
allure-combine package implementation and documentation
Then each time after running test, when want to save allure-report in one sharable HTML file:
allure generate -o allure-results-html
allure-combine ./allure-results-html
Using Nure
Read Setup Nure as pre-requisite.
nure_run_tests_generate_report.sh
-
Launch game from
App\TrashCatWindows\TrashCat.exe
-
Move to
TestAlttrashCSharp
-
Execute all tests and generate an XML output file with results
nunit3-console bin/Debug/netcoreapp3.1/TestAlttrashCSharp.dll --work=TestResults
eg: execute one test by name:
nunit3-console bin/Debug/netcoreapp3.1/TestAlttrashCSharp.dll --work=TestResults --where "name=TestNameHere"
- Transform XML to HTML report
nure TestResults/TestResult.xml -o TestResults --html