| | 1 | | using System.IO; |
| | 2 | | using GDX.Collections.Generic; |
| | 3 | | using GDX.Developer.Reports.NUnit; |
| | 4 | |
|
| | 5 | | namespace GDX.Developer.Reports |
| | 6 | | { |
| | 7 | | public static class BuildVerificationReport |
| | 8 | | { |
| 0 | 9 | | static NUnitReport s_Report = new NUnitReport("BVT", "Build Verification Test"); |
| 0 | 10 | | static SimpleList<string> s_PanicMessages = new SimpleList<string>(2); |
| | 11 | |
|
| | 12 | | public static string OutputReport(string outputPath) |
| 0 | 13 | | { |
| 0 | 14 | | if (s_PanicMessages.Count > 0) |
| 0 | 15 | | { |
| 0 | 16 | | s_Report.SetForceFail(); |
| 0 | 17 | | } |
| | 18 | |
|
| 0 | 19 | | Platform.ForceDeleteFile(outputPath); |
| 0 | 20 | | File.WriteAllText(outputPath, s_Report.ToString()); |
| 0 | 21 | | return s_Report.GetResult(); |
| 0 | 22 | | } |
| | 23 | |
|
| | 24 | | public static TestCase Assert(string identifier, bool condition, string failMessage = null, int duration = 0) |
| 0 | 25 | | { |
| 0 | 26 | | TestCase test = s_Report.AddDurationResult(identifier, duration, condition, failMessage); |
| 0 | 27 | | if (test.Result == NUnitReport.PassedString) |
| 0 | 28 | | { |
| 0 | 29 | | UnityEngine.Debug.Log($"{test.Name}: {test.Result}"); |
| 0 | 30 | | } |
| | 31 | | else |
| 0 | 32 | | { |
| 0 | 33 | | UnityEngine.Debug.Log($"{test.Name}: {test.Result}, {test.Message}"); |
| 0 | 34 | | } |
| | 35 | |
|
| 0 | 36 | | return test; |
| 0 | 37 | | } |
| | 38 | |
|
| | 39 | | public static void Reset() |
| 0 | 40 | | { |
| 0 | 41 | | s_Report = new NUnitReport(); |
| 0 | 42 | | s_PanicMessages.Clear(); |
| 0 | 43 | | } |
| | 44 | |
|
| | 45 | | public static TestCase Skip(string identifier, string skipMessage) |
| 0 | 46 | | { |
| 0 | 47 | | TestCase test = s_Report.AddSkippedTest(identifier, skipMessage); |
| 0 | 48 | | UnityEngine.Debug.Log($"{test.Name}: {test.Result}"); |
| 0 | 49 | | return test; |
| 0 | 50 | | } |
| | 51 | |
|
| | 52 | | public static void Panic(string panicMessage) |
| 0 | 53 | | { |
| 0 | 54 | | s_PanicMessages.AddWithExpandCheck(panicMessage); |
| 0 | 55 | | UnityEngine.Debug.LogError($"PANIC! {panicMessage}"); |
| 0 | 56 | | } |
| | 57 | | } |
| | 58 | | } |