A game about forced loneliness, made by TACStudios
1using UnityEngine.TestRunner;
2using Unity.PerformanceTesting;
3using NUnit.Framework;
4using NUnit.Framework.Interfaces;
5using Unity.PerformanceTesting.Data;
6using Unity.PerformanceTesting.Runtime;
7using UnityEngine.Scripting;
8using UnityEngine;
9
10[assembly: TestRunCallback(typeof(PlayerCallbacks))]
11
12namespace Unity.PerformanceTesting
13{
14 [Preserve]
15 internal class PlayerCallbacks : ITestRunCallback
16 {
17 internal static bool Saved { get; set; }
18
19 public void RunStarted(ITest testsToRun)
20 {
21 // This method is empty because it's part of the NUnit framework's ITestListener interface,
22 // which Unity uses for running tests in the Editor. It receives a parameter "testsToRun" but
23 // doesn't require implementation as Unity can execute tests without it. Developers can add
24 // custom initialization logic if needed.
25 }
26
27 public void RunFinished(ITestResult testResults)
28 {
29 Saved = false;
30 }
31
32 public void TestStarted(ITest test)
33 {
34 // This method is called by Unity when a new test has started. It receives a parameter "test"
35 // which contains information about the test being executed. Developers can add custom logic
36 // in this method, such as logging or setup code for the test.
37 }
38
39 public void TestFinished(ITestResult result)
40 {
41 // This method is called by Unity when a test has finished executing. It receives a parameter
42 // "result" which contains information about the test execution, such as whether the test
43 // passed or failed, and any messages or exceptions thrown during the test. Developers can
44 // add custom logic in this method, such as logging or teardown code for the test.
45 }
46
47 internal static void LogMetadata()
48 {
49 if (Saved) return;
50
51 var run = Metadata.GetFromResources();
52 var json = JsonUtility.ToJson(run);
53 TestContext.Out?.WriteLine("##performancetestruninfo2:" + json);
54 Saved = true;
55 }
56 }
57}