diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7ae3832..aa83c99 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -35,5 +35,12 @@ jobs: - name: Expose as artifact uses: actions/upload-artifact@v1 with: - name: test results + name: 2019.2 test results path: sample-project/playmode-results.xml + + # Upload artifact + - name: Expose as artifact + uses: actions/upload-artifact@v1 + with: + name: 2019.3 test results + path: sample-project/test-results.xml diff --git a/sample-project/Assets/Tests/EditMode/SampleEditModeTest.cs b/sample-project/Assets/Tests/EditMode/SampleEditModeTest.cs index 9ca2c9e..8eb0e03 100644 --- a/sample-project/Assets/Tests/EditMode/SampleEditModeTest.cs +++ b/sample-project/Assets/Tests/EditMode/SampleEditModeTest.cs @@ -19,6 +19,8 @@ namespace Tests // Then Assert.AreEqual(1, counter.Count); + + Assert.True(false); } [Test] @@ -26,13 +28,13 @@ namespace Tests { // Given var counter = new BasicCounter(BasicCounter.MaxCount); - + // When counter.Increment(); - + // Then Assert.AreEqual(BasicCounter.MaxCount, counter.Count); } - + } } diff --git a/sample-project/Assets/Tests/EditMode/SampleEditModeTest.cs.meta b/sample-project/Assets/Tests/EditMode/SampleEditModeTest.cs.meta index 251130d..5b8e080 100644 --- a/sample-project/Assets/Tests/EditMode/SampleEditModeTest.cs.meta +++ b/sample-project/Assets/Tests/EditMode/SampleEditModeTest.cs.meta @@ -6,6 +6,6 @@ MonoImporter: defaultReferences: [] executionOrder: 0 icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: + userData: + assetBundleName: + assetBundleVariant: diff --git a/sample-project/Assets/Tests/PlayMode/SamplePlayModeTest.cs b/sample-project/Assets/Tests/PlayMode/SamplePlayModeTest.cs index 41cab67..a1cf856 100644 --- a/sample-project/Assets/Tests/PlayMode/SamplePlayModeTest.cs +++ b/sample-project/Assets/Tests/PlayMode/SamplePlayModeTest.cs @@ -14,6 +14,8 @@ namespace Tests { // Use the Assert class to test conditions Assert.True(true); + + Assert.True(false); } // A UnityTest behaves like a coroutine in Play Mode. In Edit Mode you can use diff --git a/sample-project/Assets/Tests/PlayMode/SamplePlayModeTest.cs.meta b/sample-project/Assets/Tests/PlayMode/SamplePlayModeTest.cs.meta index 87527fb..71d02a1 100644 --- a/sample-project/Assets/Tests/PlayMode/SamplePlayModeTest.cs.meta +++ b/sample-project/Assets/Tests/PlayMode/SamplePlayModeTest.cs.meta @@ -6,6 +6,6 @@ MonoImporter: defaultReferences: [] executionOrder: 0 icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: + userData: + assetBundleName: + assetBundleVariant: diff --git a/sample-project/ProjectSettings/ProjectSettings.asset b/sample-project/ProjectSettings/ProjectSettings.asset index ab1de6a..f520a82 100644 --- a/sample-project/ProjectSettings/ProjectSettings.asset +++ b/sample-project/ProjectSettings/ProjectSettings.asset @@ -323,7 +323,7 @@ PlayerSettings: tvOS: 1 m_BuildTargetGroupLightmapEncodingQuality: [] m_BuildTargetGroupLightmapSettings: [] - playModeTestRunnerEnabled: 0 + playModeTestRunnerEnabled: 1 runPlayModeTestAsEditModeTest: 0 actionOnDotNetUnhandledException: 1 enableInternalProfiler: 0 diff --git a/test-runner/entrypoint.sh b/test-runner/entrypoint.sh index 4745636..9ef51f1 100644 --- a/test-runner/entrypoint.sh +++ b/test-runner/entrypoint.sh @@ -26,20 +26,39 @@ echo $? # Exit code is now 0 -echo "Testing project for $TEST_PLATFORM" +echo "Testing the 2019.2 way" +# Reference: https://docs.unity3d.com/2019.2/Documentation/Manual/CommandLineArguments.html echo "Using path: $UNITY_PROJECT_PATH" ls -alh $UNITY_PROJECT_PATH xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \ /opt/Unity/Editor/Unity \ -batchmode \ - -nographics \ - -logFile /dev/stdout \ + -logfile /dev/stdout \ -runEditorTests "$UNITY_PROJECT_PATH" \ -editorTestsResultFile "$UNITY_PROJECT_PATH/$TEST_PLATFORM-results.xml" -# -projectPath "$GITHUB_WORKSPACE" \ -# -testPlatform $TEST_PLATFORM \ -# -testResults "$GITHUB_WORKSPACE/$TEST_PLATFORM-results.xml" \ -# -runTests + +UNITY_EXIT_CODE=$? + +if [ $UNITY_EXIT_CODE -eq 0 ]; then + echo "Run succeeded, no failures occurred"; +elif [ $UNITY_EXIT_CODE -eq 2 ]; then + echo "Run succeeded, some tests failed"; +elif [ $UNITY_EXIT_CODE -eq 3 ]; then + echo "Run failure (other failure)"; +else + echo "Unexpected exit code $UNITY_EXIT_CODE"; +fi + +ls -alh $UNITY_PROJECT_PATH +echo "Testing the 2019.3 way" +# Reference: https://docs.unity3d.com/2019.3/Documentation/Manual/CommandLineArguments.html +xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \ + /opt/Unity/Editor/Unity \ + -batchmode \ + -logfile /dev/stdout \ + -runTests "$UNITY_PROJECT_PATH" \ + -testPlatfrom playmode \ + -testResults "$UNITY_PROJECT_PATH/test-results.xml" UNITY_EXIT_CODE=$? @@ -54,6 +73,8 @@ else fi echo "Results: " -cat $GITHUB_WORKSPACE/$TEST_PLATFORM-results.xml -cat $GITHUB_WORKSPACE/$TEST_PLATFORM-results.xml | grep test-run | grep Passed +cat "$UNITY_PROJECT_PATH/$TEST_PLATFORM-results.xml" +cat "$UNITY_PROJECT_PATH/$TEST_PLATFORM-results.xml" | grep test-run | grep Passed +cat "$UNITY_PROJECT_PATH/test-results.xml" +cat "$UNITY_PROJECT_PATH/test-results.xml" | grep test-run | grep Passed exit $UNITY_EXIT_CODE