com.valectric.mooserunner 2.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/CLI~/mooserunnerCli.exe +0 -0
- package/CLI~/mooserunnerCliDaemon.exe +0 -0
- package/Editor/GUI/MooseRunnerFail.png +0 -0
- package/Editor/GUI/MooseRunnerFail.png.meta +140 -0
- package/Editor/GUI/MooseRunnerGreenLED.png +0 -0
- package/Editor/GUI/MooseRunnerGreenLED.png.meta +140 -0
- package/Editor/GUI/MooseRunnerLogoBannerSmall.png +0 -0
- package/Editor/GUI/MooseRunnerLogoBannerSmall.png.meta +140 -0
- package/Editor/GUI/MooseRunnerNotRun.png +0 -0
- package/Editor/GUI/MooseRunnerNotRun.png.meta +140 -0
- package/Editor/GUI/MooseRunnerPass.png +0 -0
- package/Editor/GUI/MooseRunnerPass.png.meta +140 -0
- package/Editor/GUI/MooseRunnerYellowLED.png +0 -0
- package/Editor/GUI/MooseRunnerYellowLED.png.meta +140 -0
- package/Editor/MooseRunner.Editor.asmdef +17 -0
- package/Editor/MooseRunner.Editor.asmdef.meta +7 -0
- package/Editor/MooseRunner.Internal.Editor.dll +0 -0
- package/Editor/MooseRunner.Internal.Editor.dll.meta +33 -0
- package/Editor/MooseRunner.SessionRecorder.dll +0 -0
- package/Editor/MooseRunner.SessionRecorder.dll.meta +33 -0
- package/Editor/MooseRunner.Worker.dll +0 -0
- package/Editor/MooseRunner.Worker.dll.meta +33 -0
- package/Editor/_WrapperStub.cs +3 -0
- package/Editor/_WrapperStub.cs.meta +11 -0
- package/LICENSE.md +28 -0
- package/README.md +347 -0
- package/Runtime/Helpers/DoNotDestroyOnTeardown/DoNotDestroyOnTeardown.cs +262 -0
- package/Runtime/Helpers/DoNotDestroyOnTeardown/DoNotDestroyOnTeardown.cs.meta +2 -0
- package/Runtime/Helpers/DoNotDestroyOnTeardown/MooseRunner.helper.asmdef +18 -0
- package/Runtime/Helpers/DoNotDestroyOnTeardown/MooseRunner.helper.asmdef.meta +7 -0
- package/Runtime/MooseRunner.Helpers.Runtime.dll +0 -0
- package/Runtime/MooseRunner.Helpers.Runtime.dll.meta +27 -0
- package/Runtime/MooseRunner.Internal.dll +0 -0
- package/Runtime/MooseRunner.Internal.dll.meta +27 -0
- package/Runtime/MooseRunner.Multiplaytest.Types.dll +0 -0
- package/Runtime/MooseRunner.Multiplaytest.Types.dll.meta +27 -0
- package/Runtime/MooseRunner.Runtime.asmdef +20 -0
- package/Runtime/MooseRunner.Runtime.asmdef.meta +7 -0
- package/Runtime/MooseRunner.SessionRecorder.Runtime.dll +0 -0
- package/Runtime/MooseRunner.SessionRecorder.Runtime.dll.meta +27 -0
- package/Runtime/MooseRunner.dll +0 -0
- package/Runtime/MooseRunner.dll.meta +27 -0
- package/Runtime/_WrapperStub.cs +3 -0
- package/Runtime/_WrapperStub.cs.meta +11 -0
- package/Samples~/Demos/MooseRunner.Demo.CancellationTokens.Tests/BatchCancellationTests.cs +37 -0
- package/Samples~/Demos/MooseRunner.Demo.CancellationTokens.Tests/BatchCancellationTests.cs.meta +2 -0
- package/Samples~/Demos/MooseRunner.Demo.CancellationTokens.Tests/CancellationTokenTests.cs +186 -0
- package/Samples~/Demos/MooseRunner.Demo.CancellationTokens.Tests/CancellationTokenTests.cs.meta +2 -0
- package/Samples~/Demos/MooseRunner.Demo.CancellationTokens.Tests/MooseRunner.Demo.CancellationTokens.Tests.asmdef +28 -0
- package/Samples~/Demos/MooseRunner.Demo.CancellationTokens.Tests/MooseRunner.Demo.CancellationTokens.Tests.asmdef.meta +7 -0
- package/Samples~/Demos/MooseRunner.Demo.CancellationTokens.Tests/SetupTeardownCancellationTests.cs +84 -0
- package/Samples~/Demos/MooseRunner.Demo.CancellationTokens.Tests/SetupTeardownCancellationTests.cs.meta +2 -0
- package/Samples~/Demos/MooseRunner.Demo.CancellationTokens.Tests/TESTING_INSTRUCTIONS.md +491 -0
- package/Samples~/Demos/MooseRunner.Demo.CancellationTokens.Tests/TESTING_INSTRUCTIONS.md.meta +7 -0
- package/Samples~/Demos/MooseRunner.Demo.ErrorHandling.Tests/ErrorHandelingTest.cs +177 -0
- package/Samples~/Demos/MooseRunner.Demo.ErrorHandling.Tests/ErrorHandelingTest.cs.meta +11 -0
- package/Samples~/Demos/MooseRunner.Demo.ErrorHandling.Tests/MooseRunner.Demo.ErrorHandling.Tests.asmdef +28 -0
- package/Samples~/Demos/MooseRunner.Demo.ErrorHandling.Tests/MooseRunner.Demo.ErrorHandling.Tests.asmdef.meta +7 -0
- package/Samples~/Demos/MooseRunner.Demo.Flow.TestSupport/LogEntry.cs +51 -0
- package/Samples~/Demos/MooseRunner.Demo.Flow.TestSupport/LogEntry.cs.meta +11 -0
- package/Samples~/Demos/MooseRunner.Demo.Flow.TestSupport/LogFileParser.cs +70 -0
- package/Samples~/Demos/MooseRunner.Demo.Flow.TestSupport/LogFileParser.cs.meta +11 -0
- package/Samples~/Demos/MooseRunner.Demo.Flow.TestSupport/MooseRunner.Demo.Flow.TestSupport.asmdef +22 -0
- package/Samples~/Demos/MooseRunner.Demo.Flow.TestSupport/MooseRunner.Demo.Flow.TestSupport.asmdef.meta +7 -0
- package/Samples~/Demos/MooseRunner.Demo.Flow.TestSupport/MooseRunnerLogReference.json +62 -0
- package/Samples~/Demos/MooseRunner.Demo.Flow.TestSupport/MooseRunnerLogReference.json.meta +7 -0
- package/Samples~/Demos/MooseRunner.Demo.Flow.TestSupport/MooseRunnerLogReference_2.json +33 -0
- package/Samples~/Demos/MooseRunner.Demo.Flow.TestSupport/MooseRunnerLogReference_2.json.meta +7 -0
- package/Samples~/Demos/MooseRunner.Demo.Flow.TestSupport/MooseRunnerLogReference_No_UniTask.json +57 -0
- package/Samples~/Demos/MooseRunner.Demo.Flow.TestSupport/MooseRunnerLogReference_No_UniTask.json.meta +7 -0
- package/Samples~/Demos/MooseRunner.Demo.OrderAttribute/MethodOrderAttributeTests.cs +62 -0
- package/Samples~/Demos/MooseRunner.Demo.OrderAttribute/MethodOrderAttributeTests.cs.meta +2 -0
- package/Samples~/Demos/MooseRunner.Demo.OrderAttribute/MooseRunner.Demo.OrderAttribute.asmdef +20 -0
- package/Samples~/Demos/MooseRunner.Demo.OrderAttribute/MooseRunner.Demo.OrderAttribute.asmdef.meta +7 -0
- package/Samples~/Demos/MooseRunner.Demo.RealUseCase/CatAnimation.controller +276 -0
- package/Samples~/Demos/MooseRunner.Demo.RealUseCase/CatAnimation.controller.meta +8 -0
- package/Samples~/Demos/MooseRunner.Demo.RealUseCase/Enemy.cs +101 -0
- package/Samples~/Demos/MooseRunner.Demo.RealUseCase/Enemy.cs.meta +11 -0
- package/Samples~/Demos/MooseRunner.Demo.RealUseCase/FireComponent.cs +19 -0
- package/Samples~/Demos/MooseRunner.Demo.RealUseCase/FireComponent.cs.meta +3 -0
- package/Samples~/Demos/MooseRunner.Demo.RealUseCase/Model/Ghost_cat.fbx +0 -0
- package/Samples~/Demos/MooseRunner.Demo.RealUseCase/Model/Ghost_cat.fbx.meta +547 -0
- package/Samples~/Demos/MooseRunner.Demo.RealUseCase/Model.meta +8 -0
- package/Samples~/Demos/MooseRunner.Demo.RealUseCase/MooseRunner.Demo.RealUseCase.asmdef +29 -0
- package/Samples~/Demos/MooseRunner.Demo.RealUseCase/MooseRunner.Demo.RealUseCase.asmdef.meta +7 -0
- package/Samples~/Demos/MooseRunner.Demo.RealUseCase/RealUseCaseScene.unity +4758 -0
- package/Samples~/Demos/MooseRunner.Demo.RealUseCase/RealUseCaseScene.unity.meta +7 -0
- package/Samples~/Demos/MooseRunner.Demo.RealUseCase/RealUseCaseTest.cs +307 -0
- package/Samples~/Demos/MooseRunner.Demo.RealUseCase/RealUseCaseTest.cs.meta +3 -0
- package/Samples~/Demos/MooseRunner.Demo.RealUseCase/Resources/Ghost_cat.prefab +157 -0
- package/Samples~/Demos/MooseRunner.Demo.RealUseCase/Resources/Ghost_cat.prefab.meta +7 -0
- package/Samples~/Demos/MooseRunner.Demo.RealUseCase/Resources.meta +8 -0
- package/Samples~/Demos/MooseRunner.Demo.Support/MessageDisplayManager.cs +291 -0
- package/Samples~/Demos/MooseRunner.Demo.Support/MessageDisplayManager.cs.meta +11 -0
- package/Samples~/Demos/MooseRunner.Demo.Support/MooseRunner.Demo.Support.asmdef +19 -0
- package/Samples~/Demos/MooseRunner.Demo.Support/MooseRunner.Demo.Support.asmdef.meta +7 -0
- package/Samples~/Demos/MooseRunner.Demo.Tests/DummyTestBase1.cs +71 -0
- package/Samples~/Demos/MooseRunner.Demo.Tests/DummyTestBase1.cs.meta +11 -0
- package/Samples~/Demos/MooseRunner.Demo.Tests/DummyTestClass1.cs +301 -0
- package/Samples~/Demos/MooseRunner.Demo.Tests/DummyTestClass1.cs.meta +11 -0
- package/Samples~/Demos/MooseRunner.Demo.Tests/DummyTestClass2.cs +69 -0
- package/Samples~/Demos/MooseRunner.Demo.Tests/DummyTestClass2.cs.meta +11 -0
- package/Samples~/Demos/MooseRunner.Demo.Tests/ExplicitAttributeTests.cs +36 -0
- package/Samples~/Demos/MooseRunner.Demo.Tests/ExplicitAttributeTests.cs.meta +2 -0
- package/Samples~/Demos/MooseRunner.Demo.Tests/HumanReviewModeDemo.cs +99 -0
- package/Samples~/Demos/MooseRunner.Demo.Tests/HumanReviewModeDemo.cs.meta +2 -0
- package/Samples~/Demos/MooseRunner.Demo.Tests/InstanceHandlingVerificationTest.cs +99 -0
- package/Samples~/Demos/MooseRunner.Demo.Tests/InstanceHandlingVerificationTest.cs.meta +2 -0
- package/Samples~/Demos/MooseRunner.Demo.Tests/MooseRunner.Demo.Tests.asmdef +23 -0
- package/Samples~/Demos/MooseRunner.Demo.Tests/MooseRunner.Demo.Tests.asmdef.meta +7 -0
- package/Samples~/Demos/MooseRunner.Demo.Tests/PauseTestExecutionDemo.cs +74 -0
- package/Samples~/Demos/MooseRunner.Demo.Tests/PauseTestExecutionDemo.cs.meta +2 -0
- package/Samples~/Demos/TestResources/OneCamera/Materials/Background.mat +137 -0
- package/Samples~/Demos/TestResources/OneCamera/Materials/Background.mat.meta +8 -0
- package/Samples~/Demos/TestResources/OneCamera/Materials/Background.png +0 -0
- package/Samples~/Demos/TestResources/OneCamera/Materials/Background.png.meta +127 -0
- package/Samples~/Demos/TestResources/OneCamera/Materials/Grid.mat +71 -0
- package/Samples~/Demos/TestResources/OneCamera/Materials/Grid.mat.meta +8 -0
- package/Samples~/Demos/TestResources/OneCamera/Materials/Grid.png +0 -0
- package/Samples~/Demos/TestResources/OneCamera/Materials/Grid.png.meta +127 -0
- package/Samples~/Demos/TestResources/OneCamera/Materials/Grid.shadergraph +1910 -0
- package/Samples~/Demos/TestResources/OneCamera/Materials/Grid.shadergraph.meta +10 -0
- package/Samples~/Demos/TestResources/OneCamera/Materials/GridNormal.png +0 -0
- package/Samples~/Demos/TestResources/OneCamera/Materials/GridNormal.png.meta +127 -0
- package/Samples~/Demos/TestResources/OneCamera/Materials.meta +8 -0
- package/Samples~/Demos/TestResources/OneCamera/OneCameraScene.unity +598 -0
- package/Samples~/Demos/TestResources/OneCamera/OneCameraScene.unity.meta +7 -0
- package/Samples~/Demos/TestResources/OneCamera.meta +8 -0
- package/Third Party Notices.md +37 -0
- package/package.json +38 -0
|
@@ -0,0 +1,491 @@
|
|
|
1
|
+
# CancellationToken Implementation - Manual Testing Instructions
|
|
2
|
+
|
|
3
|
+
#---------------------------------------
|
|
4
|
+
IMPORTANT! IMPORTANT! IMPORTANT!
|
|
5
|
+
If you want to use this you must first copy it over to a loaded area. This default place is
|
|
6
|
+
just for future use and will note be connected to the coade base as the package file is in a higher folder.
|
|
7
|
+
#---------------------------------------
|
|
8
|
+
|
|
9
|
+
## Files Created
|
|
10
|
+
|
|
11
|
+
1. **Test Files**:
|
|
12
|
+
- `Assets/Tests/CancellationTokenTests.cs` (main cancellation tests)
|
|
13
|
+
- `Assets/Tests/BatchCancellationTests.cs` (batch execution tests)
|
|
14
|
+
- `Assets/Tests/SetupTeardownCancellationTests.cs` (setup/teardown lifecycle tests)
|
|
15
|
+
2. **Assembly Definition**: `Assets/Tests/CancellationTokenTests.asmdef`
|
|
16
|
+
3. **This Document**: `TESTING_INSTRUCTIONS.md`
|
|
17
|
+
|
|
18
|
+
## Pre-Testing Setup
|
|
19
|
+
|
|
20
|
+
### Step 1: Open Unity
|
|
21
|
+
1. Open the CADcog project in Unity 6000.2
|
|
22
|
+
2. Wait for Unity to compile the new test files
|
|
23
|
+
|
|
24
|
+
### Step 2: Open MooseRunner Window
|
|
25
|
+
1. In Unity, go to `Window > MooseRunner` (or wherever the MooseRunner window menu is)
|
|
26
|
+
2. The MooseRunner window should open showing your test assemblies
|
|
27
|
+
|
|
28
|
+
### Step 3: Locate the Tests
|
|
29
|
+
1. In MooseRunner, look for the `CancellationTokenTests` assembly
|
|
30
|
+
2. Expand it to see the test classes:
|
|
31
|
+
- `CancellationTokenTests` (main tests - in CancellationTokenTests.cs)
|
|
32
|
+
- `BatchCancellationTests` (batch cancellation tests - in BatchCancellationTests.cs)
|
|
33
|
+
- `SetupTeardownCancellationTests` (setup/teardown tests - in SetupTeardownCancellationTests.cs)
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Manual Testing Checklist
|
|
38
|
+
|
|
39
|
+
### ✅ Test 1: Basic Task Cancellation
|
|
40
|
+
|
|
41
|
+
**What to do:**
|
|
42
|
+
1. Select `Test1_BasicTaskCancellation_ShouldStopImmediately`
|
|
43
|
+
2. Click **Run** button in MooseRunner
|
|
44
|
+
3. Observe console message: `[Test1] Test started - will delay for 10 seconds`
|
|
45
|
+
4. **Within 1-2 seconds, click the STOP button**
|
|
46
|
+
5. Observe the results
|
|
47
|
+
|
|
48
|
+
**Expected Results:**
|
|
49
|
+
- ✅ Test stops immediately (doesn't wait 10 seconds)
|
|
50
|
+
- ✅ Console shows: `Test Test1_BasicTaskCancellation_ShouldStopImmediately was cancelled`
|
|
51
|
+
- ✅ Console shows: `[Test1] SUCCESS: Cancellation was properly caught by test method`
|
|
52
|
+
- ✅ Test status shows "Failed" (because cancelled tests currently marked as failed)
|
|
53
|
+
- ❌ **FAIL IF**: Test continues for 10 seconds
|
|
54
|
+
|
|
55
|
+
**Status:** [ ] PASS [ ] FAIL
|
|
56
|
+
|
|
57
|
+
**Notes:**
|
|
58
|
+
_______________________________________
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
### ✅ Test 2: Cooperative Loop Cancellation
|
|
63
|
+
|
|
64
|
+
**What to do:**
|
|
65
|
+
1. Select `Test2_CooperativeLoop_ShouldExitEarly`
|
|
66
|
+
2. Click **Run**
|
|
67
|
+
3. Watch console iterations: `[Test2] Iteration 0`, `[Test2] Iteration 1`, etc.
|
|
68
|
+
4. **After ~5 iterations, click STOP**
|
|
69
|
+
|
|
70
|
+
**Expected Results:**
|
|
71
|
+
- ✅ Loop exits immediately
|
|
72
|
+
- ✅ Remaining 95 iterations don't execute
|
|
73
|
+
- ✅ Console shows cancellation message
|
|
74
|
+
- ❌ **FAIL IF**: All 100 iterations complete
|
|
75
|
+
|
|
76
|
+
**Status:** [ ] PASS [ ] FAIL
|
|
77
|
+
|
|
78
|
+
**Notes:**
|
|
79
|
+
_______________________________________
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
### ✅ Test 3: Multiple Operations Cancellation
|
|
84
|
+
|
|
85
|
+
**What to do:**
|
|
86
|
+
1. Select `Test3_MultipleOperations_AllCancelTogether`
|
|
87
|
+
2. Click **Run**
|
|
88
|
+
3. Observe console: `[Test3] Starting 3 parallel 5-second delays`
|
|
89
|
+
4. **Within 1-2 seconds, click STOP**
|
|
90
|
+
|
|
91
|
+
**Expected Results:**
|
|
92
|
+
- ✅ All three operations cancel together
|
|
93
|
+
- ✅ Test stops immediately
|
|
94
|
+
- ✅ Console shows cancellation message
|
|
95
|
+
- ❌ **FAIL IF**: Test waits 5 seconds
|
|
96
|
+
|
|
97
|
+
**Status:** [ ] PASS [ ] FAIL
|
|
98
|
+
|
|
99
|
+
**Notes:**
|
|
100
|
+
_______________________________________
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
### ✅ Test 4: UniTask Cancellation (if UNITASK_PRESENT)
|
|
105
|
+
|
|
106
|
+
**What to do:**
|
|
107
|
+
1. Check if UniTask is installed in your project
|
|
108
|
+
2. If not installed, skip this test
|
|
109
|
+
3. If installed, select `Test4_UniTaskCancellation_ShouldStopImmediately`
|
|
110
|
+
4. Click **Run**
|
|
111
|
+
5. **Within 1-2 seconds, click STOP**
|
|
112
|
+
|
|
113
|
+
**Expected Results:**
|
|
114
|
+
- ✅ UniTask cancels immediately
|
|
115
|
+
- ✅ Console shows: `[Test4] SUCCESS: UniTask cancellation was properly caught`
|
|
116
|
+
- ✅ Same behavior as Test 1 but for UniTask
|
|
117
|
+
- ❌ **FAIL IF**: Test runs for 10 seconds
|
|
118
|
+
|
|
119
|
+
**Status:** [ ] PASS [ ] FAIL [ ] SKIPPED (no UniTask)
|
|
120
|
+
|
|
121
|
+
**Notes:**
|
|
122
|
+
_______________________________________
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
### ✅ Test 5: Backward Compatibility (Func<bool>)
|
|
127
|
+
|
|
128
|
+
**What to do:**
|
|
129
|
+
1. Select `Test5_BackwardCompatibility_FuncBoolStillWorks`
|
|
130
|
+
2. Click **Run**
|
|
131
|
+
3. Observe iterations in console
|
|
132
|
+
4. **After 2-3 iterations, click STOP**
|
|
133
|
+
|
|
134
|
+
**Expected Results:**
|
|
135
|
+
- ✅ Test stops using legacy mechanism
|
|
136
|
+
- ✅ Console shows: `[Test5] SUCCESS: Stopped via Func<bool> at iteration X`
|
|
137
|
+
- ✅ No errors or warnings
|
|
138
|
+
- ✅ Proves old pattern still works
|
|
139
|
+
- ❌ **FAIL IF**: Stop button doesn't work
|
|
140
|
+
|
|
141
|
+
**Status:** [ ] PASS [ ] FAIL
|
|
142
|
+
|
|
143
|
+
**Notes:**
|
|
144
|
+
_______________________________________
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
### ✅ Test 6: No Parameters Test
|
|
149
|
+
|
|
150
|
+
**What to do:**
|
|
151
|
+
1. Select `Test6_NoParameters_RunsNormally`
|
|
152
|
+
2. Click **Run**
|
|
153
|
+
3. **DO NOT click STOP** - let it complete
|
|
154
|
+
4. Observe it runs for 2 seconds and completes
|
|
155
|
+
|
|
156
|
+
**Expected Results:**
|
|
157
|
+
- ✅ Test completes normally
|
|
158
|
+
- ✅ Console shows: `[Test6] Test completed successfully`
|
|
159
|
+
- ✅ Test passes (green)
|
|
160
|
+
- ⚠️ Note: Stop button won't work for tests without cancellation parameters
|
|
161
|
+
|
|
162
|
+
**Status:** [ ] PASS [ ] FAIL
|
|
163
|
+
|
|
164
|
+
**Notes:**
|
|
165
|
+
_______________________________________
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
### ✅ Test 7: Long Running Test
|
|
170
|
+
|
|
171
|
+
**What to do:**
|
|
172
|
+
1. Select `Test7_LongRunning_CancellableAnytime`
|
|
173
|
+
2. Click **Run**
|
|
174
|
+
3. Wait for random number of seconds (e.g., 7 seconds)
|
|
175
|
+
4. Click **STOP**
|
|
176
|
+
|
|
177
|
+
**Expected Results:**
|
|
178
|
+
- ✅ Test stops immediately at any point
|
|
179
|
+
- ✅ Doesn't complete the full 30 seconds
|
|
180
|
+
- ✅ Console shows cancellation message
|
|
181
|
+
- ❌ **FAIL IF**: Test continues after clicking Stop
|
|
182
|
+
|
|
183
|
+
**Status:** [ ] PASS [ ] FAIL
|
|
184
|
+
|
|
185
|
+
**Notes:**
|
|
186
|
+
_______________________________________
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
### ✅ Test 8: Timeout Attribute
|
|
191
|
+
|
|
192
|
+
**What to do:**
|
|
193
|
+
1. Select `Test8_Timeout_ShouldFailAfter2Seconds`
|
|
194
|
+
2. Click **Run**
|
|
195
|
+
3. **DO NOT click STOP** - let the timeout trigger automatically
|
|
196
|
+
4. Observe the test behavior
|
|
197
|
+
|
|
198
|
+
**Expected Results:**
|
|
199
|
+
- ✅ Test starts and logs: `[Test8] Starting test with 2-second timeout, but will try to delay for 10 seconds`
|
|
200
|
+
- ✅ Test automatically FAILS after 2 seconds (doesn't wait 10 seconds)
|
|
201
|
+
- ✅ Console shows: `Test Test8_Timeout_ShouldFailAfter2Seconds timed out`
|
|
202
|
+
- ✅ Console shows: `[Test8] Task was cancelled - timeout triggered!`
|
|
203
|
+
- ✅ **Console ERROR shows: `Test Test8_Timeout_ShouldFailAfter2Seconds did timeout`** (red error in console)
|
|
204
|
+
- ✅ Test status shows "Failed" (red)
|
|
205
|
+
- ❌ **FAIL IF**: Test runs for more than 3 seconds
|
|
206
|
+
- ❌ **FAIL IF**: Test completes successfully (green)
|
|
207
|
+
|
|
208
|
+
**Status:** [ ] PASS [ ] FAIL
|
|
209
|
+
|
|
210
|
+
**Notes:**
|
|
211
|
+
_______________________________________
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
### ✅ Test 9: Batch Cancellation
|
|
216
|
+
|
|
217
|
+
**What to do:**
|
|
218
|
+
1. Select ALL THREE tests in `BatchCancellationTests`:
|
|
219
|
+
- `BatchTest1_TwoSeconds`
|
|
220
|
+
- `BatchTest2_TwoSeconds`
|
|
221
|
+
- `BatchTest3_TwoSeconds`
|
|
222
|
+
2. Click **Run All** (or select batch run)
|
|
223
|
+
3. Wait for `BatchTest1` to complete (~2 seconds)
|
|
224
|
+
4. **During `BatchTest2`, click STOP**
|
|
225
|
+
|
|
226
|
+
**Expected Results:**
|
|
227
|
+
- ✅ BatchTest1 completes and shows "Passed" (green)
|
|
228
|
+
- ✅ BatchTest2 cancels immediately and shows "Failed" (red)
|
|
229
|
+
- ✅ BatchTest3 NEVER starts and stays "NotRun" (gray)
|
|
230
|
+
- ✅ Console shows: `[Batch1] Completed`, then `[Batch2] Starting`, then cancellation message
|
|
231
|
+
- ✅ Console shows: `Test BatchTest2_TwoSeconds was stopped and marked as Failed`
|
|
232
|
+
- ❌ **FAIL IF**: BatchTest3 starts or shows anything other than gray/NotRun
|
|
233
|
+
- ❌ **FAIL IF**: BatchTest3 shows "Starting" in console
|
|
234
|
+
|
|
235
|
+
**Status:** [ ] PASS [ ] FAIL
|
|
236
|
+
|
|
237
|
+
**Notes:**
|
|
238
|
+
_______________________________________
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
### ✅ Test 10: Setup Cancellation
|
|
243
|
+
|
|
244
|
+
**What to do:**
|
|
245
|
+
1. Select `SetupTeardownCancellationTests > TestMethod`
|
|
246
|
+
2. Click **Run**
|
|
247
|
+
3. Observe console: `[Setup] Setup started - 5 second delay`
|
|
248
|
+
4. **During setup (within 2 seconds), click STOP**
|
|
249
|
+
|
|
250
|
+
**Expected Results:**
|
|
251
|
+
- ✅ Setup cancels immediately (doesn't wait 5 seconds)
|
|
252
|
+
- ✅ Console shows: `[Setup] Setup started - 5 second delay`
|
|
253
|
+
- ✅ Console does NOT show: `[Setup] Setup completed`
|
|
254
|
+
- ✅ **Test method NEVER runs** - skips directly to TearDown
|
|
255
|
+
- ✅ Console does NOT show: `[TestMethod] Test is running`
|
|
256
|
+
- ✅ TearDown runs for cleanup (may show `[Teardown] Teardown started`)
|
|
257
|
+
- ✅ Test marked as "Failed" (red) - cancelled during setup
|
|
258
|
+
- ❌ **FAIL IF**: Console shows `[TestMethod] Test is running` (test should be skipped)
|
|
259
|
+
- ❌ **FAIL IF**: Setup runs for full 5 seconds
|
|
260
|
+
|
|
261
|
+
**Status:** [ ] PASS [ ] FAIL
|
|
262
|
+
|
|
263
|
+
**Notes:**
|
|
264
|
+
_______________________________________
|
|
265
|
+
|
|
266
|
+
---
|
|
267
|
+
|
|
268
|
+
### ✅ Test 11: OneTimeSetUp Cancellation
|
|
269
|
+
|
|
270
|
+
**What to do:**
|
|
271
|
+
1. Select `SetupTeardownCancellationTests > TestMethod`
|
|
272
|
+
2. Click **Run**
|
|
273
|
+
3. Observe console: `[OneTimeSetUp] OneTimeSetUp started - 5 second delay`
|
|
274
|
+
4. **During OneTimeSetUp (within 2 seconds), click STOP**
|
|
275
|
+
|
|
276
|
+
**Expected Results:**
|
|
277
|
+
- ✅ OneTimeSetUp cancels immediately (doesn't wait 5 seconds)
|
|
278
|
+
- ✅ Console shows: `[OneTimeSetUp] OneTimeSetUp started - 5 second delay`
|
|
279
|
+
- ✅ Console does NOT show: `[OneTimeSetUp] OneTimeSetUp completed`
|
|
280
|
+
- ✅ Console DOES show: `[OneTimeTearDown] OneTimeTearDown started` **immediately**
|
|
281
|
+
- ✅ Console DOES show: `[OneTimeTearDown] OneTimeTearDown completed`
|
|
282
|
+
- ✅ Console does NOT show: `[Setup] Setup started` (Setup skipped)
|
|
283
|
+
- ✅ Console does NOT show: `[TestMethod] Test is running` (Test skipped)
|
|
284
|
+
- ✅ Console does NOT show: `[Teardown] Teardown started` (TearDown skipped - Setup never ran)
|
|
285
|
+
- ✅ Test marked as "Failed" (red) - cancelled during OneTimeSetUp
|
|
286
|
+
- ❌ **FAIL IF**: Setup, Test, or TearDown execute after OneTimeSetUp cancelled
|
|
287
|
+
- ❌ **FAIL IF**: OneTimeTearDown doesn't run
|
|
288
|
+
- ❌ **FAIL IF**: TearDown executes (should be skipped because Setup never ran)
|
|
289
|
+
|
|
290
|
+
**Status:** [ ] PASS [ ] FAIL
|
|
291
|
+
|
|
292
|
+
**Notes:**
|
|
293
|
+
_______________________________________
|
|
294
|
+
|
|
295
|
+
---
|
|
296
|
+
|
|
297
|
+
### ✅ Test 12: OneTimeTearDown Execution After Failure
|
|
298
|
+
|
|
299
|
+
**What to do:**
|
|
300
|
+
1. Run Test 11 first (cancel during OneTimeSetUp)
|
|
301
|
+
2. Verify that OneTimeTearDown ran during the same execution (not when switching classes)
|
|
302
|
+
3. Observe the console messages
|
|
303
|
+
|
|
304
|
+
**Expected Results:**
|
|
305
|
+
- ✅ Console shows `[OneTimeTearDown] OneTimeTearDown started` **during the same execution** (not on class switch)
|
|
306
|
+
- ✅ Console shows `[OneTimeTearDown] OneTimeTearDown completed`
|
|
307
|
+
- ✅ Console does NOT show `[Teardown] Teardown started` (TearDown skipped)
|
|
308
|
+
- ✅ OneTimeTearDown executes even though OneTimeSetUp failed
|
|
309
|
+
- ✅ Execution flow: OneTimeSetUp (cancelled) → OneTimeTearDown → Abort
|
|
310
|
+
- ❌ **FAIL IF**: OneTimeTearDown doesn't run immediately
|
|
311
|
+
- ❌ **FAIL IF**: OneTimeTearDown waits for class switch instead of running immediately
|
|
312
|
+
- ❌ **FAIL IF**: TearDown executes (should be skipped)
|
|
313
|
+
|
|
314
|
+
**Status:** [ ] PASS [ ] FAIL
|
|
315
|
+
|
|
316
|
+
**Notes:**
|
|
317
|
+
_______________________________________
|
|
318
|
+
|
|
319
|
+
---
|
|
320
|
+
|
|
321
|
+
### ✅ Test 13: Re-run After OneTimeSetUp Failure
|
|
322
|
+
|
|
323
|
+
**What to do:**
|
|
324
|
+
1. Run `SetupTeardownCancellationTests > TestMethod`
|
|
325
|
+
2. Click STOP during OneTimeSetUp
|
|
326
|
+
3. Wait for execution to complete
|
|
327
|
+
4. Run the SAME test again (`SetupTeardownCancellationTests > TestMethod`)
|
|
328
|
+
5. **This time, let it complete without clicking STOP**
|
|
329
|
+
6. Observe console
|
|
330
|
+
|
|
331
|
+
**Expected Results:**
|
|
332
|
+
- ✅ Console shows `[OneTimeSetUp] OneTimeSetUp started` **again** on the second run
|
|
333
|
+
- ✅ OneTimeSetUp runs from scratch (doesn't skip because state was reset)
|
|
334
|
+
- ✅ If not cancelled, console shows: `[OneTimeSetUp] OneTimeSetUp completed`
|
|
335
|
+
- ✅ If not cancelled, test proceeds normally: Setup → Test → TearDown
|
|
336
|
+
- ✅ Test completes successfully (green) on second run if not cancelled
|
|
337
|
+
- ❌ **FAIL IF**: OneTimeSetUp is skipped on second run (would indicate state wasn't reset)
|
|
338
|
+
- ❌ **FAIL IF**: Console shows error about OneTimeSetUp already having run
|
|
339
|
+
|
|
340
|
+
**Status:** [ ] PASS [ ] FAIL
|
|
341
|
+
|
|
342
|
+
**Notes:**
|
|
343
|
+
_______________________________________
|
|
344
|
+
|
|
345
|
+
---
|
|
346
|
+
|
|
347
|
+
## Post-Testing Validation
|
|
348
|
+
|
|
349
|
+
### Check for Memory Leaks
|
|
350
|
+
1. Run several tests with cancellation
|
|
351
|
+
2. Check Unity Profiler for memory allocation
|
|
352
|
+
3. Verify `CancellationTokenSource` objects are being disposed
|
|
353
|
+
|
|
354
|
+
**Status:** [ ] NO LEAKS [ ] LEAKS DETECTED
|
|
355
|
+
|
|
356
|
+
**Notes:**
|
|
357
|
+
_______________________________________
|
|
358
|
+
|
|
359
|
+
### Check Console for Errors
|
|
360
|
+
1. Review all console messages
|
|
361
|
+
2. Look for any unexpected errors
|
|
362
|
+
3. Verify no stack traces from our changes
|
|
363
|
+
|
|
364
|
+
**Status:** [ ] NO ERRORS [ ] ERRORS FOUND
|
|
365
|
+
|
|
366
|
+
**Notes:**
|
|
367
|
+
_______________________________________
|
|
368
|
+
|
|
369
|
+
---
|
|
370
|
+
|
|
371
|
+
## Known Limitations (Expected Behavior)
|
|
372
|
+
|
|
373
|
+
1. **Cancelled tests show as "Failed"** - This is expected. We're using the existing `MethodTestStatus.Failed` for cancelled tests. In the future, we can add a "Skipped" status.
|
|
374
|
+
|
|
375
|
+
2. **Tests without parameters cannot be cancelled** - This is expected. Only tests with `CancellationToken` or `Func<bool>` parameters can be stopped.
|
|
376
|
+
|
|
377
|
+
3. **Coroutines still use old mechanism** - This is expected. IEnumerator tests continue to use the `_stopTestNow` flag and `StopCoroutine()`.
|
|
378
|
+
|
|
379
|
+
## Important Fix Applied
|
|
380
|
+
|
|
381
|
+
**ISSUE FIXED**: Previously, Test5 (Func<bool>) and coroutine tests would be marked as **Passed** when stopped because they exited cleanly without throwing exceptions.
|
|
382
|
+
|
|
383
|
+
**FIX**: Now ALL tests (CancellationToken, Func<bool>, and coroutines) are properly marked as **Failed** when the Stop button is clicked. This happens in `TestMethodExecutor.StopExecution()` which now tracks and marks the currently executing test as Failed.
|
|
384
|
+
|
|
385
|
+
**What This Means**: Test5 should now correctly show as "Failed" when you click Stop, just like Tests 1-4.
|
|
386
|
+
|
|
387
|
+
## Important Fix #2: Batch Test Blocking
|
|
388
|
+
|
|
389
|
+
**ISSUE FIXED**: Previously, when running batch tests and clicking Stop during Test2, Test3 would still start after Test2 completed.
|
|
390
|
+
|
|
391
|
+
**ROOT CAUSE**:
|
|
392
|
+
1. Race condition in `TestExecutorAPI.StopTestExecution()` - batch flag was set AFTER method executor stop, allowing callbacks to fire first
|
|
393
|
+
2. Missing stop checks in recursive callbacks - callbacks would start the next test without checking if stop was requested
|
|
394
|
+
|
|
395
|
+
**FIXES APPLIED**:
|
|
396
|
+
1. **Reordered stop calls** in `TestExecutorAPI.cs`: Batch flag now set BEFORE stopping method executor
|
|
397
|
+
2. **Added stop checks** in `TestBatchRunner.cs`: All 4 recursive callbacks now check `_stopTestNow` before starting next test
|
|
398
|
+
|
|
399
|
+
**What This Means**:
|
|
400
|
+
- When you stop during Test2, Test2 will be marked as Failed (red)
|
|
401
|
+
- Test3 will NOT start - it stays gray (NotRun)
|
|
402
|
+
- This applies to all batch execution scenarios (methods, classes, assemblies)
|
|
403
|
+
|
|
404
|
+
---
|
|
405
|
+
|
|
406
|
+
## Important Fix #3: OneTimeTearDown Execution After OneTimeSetUp Failure
|
|
407
|
+
|
|
408
|
+
**ISSUE FIXED**: Previously, when OneTimeSetUp was cancelled or failed, OneTimeTearDown would never run, causing resource leaks.
|
|
409
|
+
|
|
410
|
+
**ROOT CAUSE**:
|
|
411
|
+
1. When OneTimeSetUp failed, code would set `_lastTestClassRun = null` immediately
|
|
412
|
+
2. This prevented OneTimeTearDown from executing (check requires `_lastTestClassRun != null`)
|
|
413
|
+
3. But setting to null is NECESSARY - otherwise re-running the test would skip OneTimeSetUp (thinking it already succeeded)
|
|
414
|
+
4. TearDown would run even though Setup never ran (nothing to tear down)
|
|
415
|
+
|
|
416
|
+
**FIX APPLIED**:
|
|
417
|
+
**File**: `TestLifecycleRunner.cs` (lines 118-126)
|
|
418
|
+
|
|
419
|
+
**New behavior when OneTimeSetUp fails**:
|
|
420
|
+
1. Run **OneTimeTearDown immediately** for cleanup (before resetting state)
|
|
421
|
+
2. Then set `_lastTestClassRun = null` to reset state
|
|
422
|
+
3. Then call `onComplete()` to abort execution
|
|
423
|
+
4. **Skip Setup, Test, AND TearDown** entirely (Setup never ran, nothing to tear down)
|
|
424
|
+
|
|
425
|
+
**What This Means**:
|
|
426
|
+
- When OneTimeSetUp is cancelled, OneTimeTearDown runs immediately for resource cleanup
|
|
427
|
+
- TearDown is now correctly skipped (Setup never ran)
|
|
428
|
+
- State is reset, allowing OneTimeSetUp to run again on next execution
|
|
429
|
+
- No resource leaks from partial OneTimeSetUp execution
|
|
430
|
+
- Correct lifecycle: OneTimeSetUp (failed) → OneTimeTearDown → Reset → Abort
|
|
431
|
+
|
|
432
|
+
---
|
|
433
|
+
|
|
434
|
+
## Troubleshooting
|
|
435
|
+
|
|
436
|
+
### Tests don't appear in MooseRunner
|
|
437
|
+
- **Solution**: Check Unity Console for compilation errors
|
|
438
|
+
- **Solution**: Verify `CancellationTokenTests.asmdef` was created correctly
|
|
439
|
+
- **Solution**: Reimport the Assets/Tests folder
|
|
440
|
+
|
|
441
|
+
### Stop button doesn't work
|
|
442
|
+
- **Solution**: Verify you're in Play Mode (MooseRunner only supports stopping in Play Mode)
|
|
443
|
+
- **Solution**: Check that test has `CancellationToken` parameter
|
|
444
|
+
- **Solution**: Review TestMethodExecutor.cs changes are correct
|
|
445
|
+
|
|
446
|
+
### Compilation errors
|
|
447
|
+
- **Solution**: Verify `using System.Threading;` was added to TestMethodExecutor.cs
|
|
448
|
+
- **Solution**: Check Unity version is 6000.2 or compatible
|
|
449
|
+
- **Solution**: Review all edits were applied correctly
|
|
450
|
+
|
|
451
|
+
---
|
|
452
|
+
|
|
453
|
+
## Summary Checklist
|
|
454
|
+
|
|
455
|
+
After completing all tests, verify:
|
|
456
|
+
|
|
457
|
+
- [ ] All CancellationToken tests can be cancelled immediately
|
|
458
|
+
- [ ] Timeout attribute automatically cancels tests after specified duration
|
|
459
|
+
- [ ] Backward compatibility maintained (Func<bool> still works)
|
|
460
|
+
- [ ] Batch cancellation stops current test and skips remaining
|
|
461
|
+
- [ ] Setup/Teardown cancellation works correctly
|
|
462
|
+
- [ ] OneTimeSetUp cancellation triggers OneTimeTearDown immediately
|
|
463
|
+
- [ ] OneTimeTearDown runs even when OneTimeSetUp fails
|
|
464
|
+
- [ ] TearDown is skipped when OneTimeSetUp fails (Setup never ran)
|
|
465
|
+
- [ ] Re-running test after OneTimeSetUp failure runs OneTimeSetUp again (state reset)
|
|
466
|
+
- [ ] No memory leaks detected
|
|
467
|
+
- [ ] No unexpected errors in console
|
|
468
|
+
- [ ] Tests without parameters still run normally
|
|
469
|
+
|
|
470
|
+
---
|
|
471
|
+
|
|
472
|
+
## Next Steps
|
|
473
|
+
|
|
474
|
+
Once manual testing is complete:
|
|
475
|
+
|
|
476
|
+
1. **Document Results**: Fill in all the [ ] PASS/FAIL checkboxes above
|
|
477
|
+
2. **Report Issues**: If any tests fail, document exactly what happened
|
|
478
|
+
3. **Review Implementation**: If everything passes, the implementation is validated
|
|
479
|
+
4. **Consider Future Enhancements**:
|
|
480
|
+
- Add `MethodTestStatus.Skipped` enum value for cancelled tests
|
|
481
|
+
- Add timeout support via linked CancellationTokenSource
|
|
482
|
+
- Update UI to show cancellation vs failure distinctly
|
|
483
|
+
|
|
484
|
+
---
|
|
485
|
+
|
|
486
|
+
## Questions?
|
|
487
|
+
|
|
488
|
+
If you encounter any issues or have questions about the tests:
|
|
489
|
+
1. Check the test code comments in `CancellationTokenTests.cs`
|
|
490
|
+
2. Review `plan.md` for detailed implementation details
|
|
491
|
+
3. Check Unity console for error messages
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
using System.Collections;
|
|
2
|
+
using MooseRunner.Internal.Tests;
|
|
3
|
+
using NUnit.Framework;
|
|
4
|
+
using UnityEngine;
|
|
5
|
+
using UnityEngine.TestTools;
|
|
6
|
+
using System.Threading.Tasks;
|
|
7
|
+
using System;
|
|
8
|
+
using UnityEngine.SceneManagement;
|
|
9
|
+
using MooseRunner.Multiplaytest;
|
|
10
|
+
|
|
11
|
+
#if UNITASK_PRESENT
|
|
12
|
+
using Cysharp.Threading.Tasks;
|
|
13
|
+
#endif
|
|
14
|
+
|
|
15
|
+
namespace MooseRunner.Internal.Tests
|
|
16
|
+
{
|
|
17
|
+
public class ErrorHandelingTest
|
|
18
|
+
{
|
|
19
|
+
/// <summary>
|
|
20
|
+
/// Sets up the test environment before any test is executed.
|
|
21
|
+
/// Ensures that the "OneCameraScene" is created with a camera.
|
|
22
|
+
/// If the scene does not exist, it creates a new scene with a camera,
|
|
23
|
+
/// unloads all other scenes, and makes the new scene active.
|
|
24
|
+
/// </summary>
|
|
25
|
+
/// <returns>An enumerator for the asynchronous setup process.</returns>
|
|
26
|
+
|
|
27
|
+
[OneTimeSetUp]
|
|
28
|
+
public async Task SetUpOnce()
|
|
29
|
+
{
|
|
30
|
+
await MooseRunnerFacade.Instance.LoadSceneFromNameAsync("OneCameraScene");
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Regular setup, called before each individual test
|
|
34
|
+
[SetUp]
|
|
35
|
+
public void SetUp()
|
|
36
|
+
{
|
|
37
|
+
Debug.Log("ErrorHandelingTest SetUp: Called before each test.");
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Dummy test that runs synchronously
|
|
41
|
+
[Test]
|
|
42
|
+
public void SyncTest()
|
|
43
|
+
{
|
|
44
|
+
Debug.Log("ErrorHandelingTest SyncTest: This is a synchronous test.");
|
|
45
|
+
MessageDisplayManager.Instance.ShowMessage("ErrorHandelingTest SyncTest");
|
|
46
|
+
Assert.IsTrue(true); // Dummy assertion
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Dummy test that runs synchronously and throws an exception
|
|
50
|
+
[Test]
|
|
51
|
+
public void SyncErrorTest_ShouldFail()
|
|
52
|
+
{
|
|
53
|
+
Debug.Log("ErrorHandelingTest SyncTest: This is a synchronous error test.");
|
|
54
|
+
MessageDisplayManager.Instance.ShowMessage(
|
|
55
|
+
"ErrorHandelingTest SyncErrorTest_ShouldFail throwing expected errors");
|
|
56
|
+
throw new System.Exception(
|
|
57
|
+
"ErrorHandelingTest SyncErrorTest: This is a synchronous test that throws an exception.");
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Dummy test that runs in a coroutine (PlayMode)
|
|
61
|
+
[UnityTest]
|
|
62
|
+
public IEnumerator CoroutineTest()
|
|
63
|
+
{
|
|
64
|
+
Debug.Log("ErrorHandelingTest CoroutineTest: This is an coroutine test.");
|
|
65
|
+
MessageDisplayManager.Instance.ShowMessage("ErrorHandelingTest CoroutineTest no error wait for 1");
|
|
66
|
+
yield return new WaitForSeconds(1); // Simulate some asynchronous behavior
|
|
67
|
+
MessageDisplayManager.Instance.ShowMessage("ErrorHandelingTest CoroutineTest no error wait for 0");
|
|
68
|
+
Assert.IsTrue(true); // Dummy assertion
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Dummy test that runs in a coroutine and throws an exception (PlayMode)
|
|
72
|
+
[UnityTest]
|
|
73
|
+
public IEnumerator CoroutineErrorTest_ShouldFail()
|
|
74
|
+
{
|
|
75
|
+
Debug.Log("ErrorHandelingTest CoroutineErrorTest_ShouldFail: This is an coroutine Error test.");
|
|
76
|
+
MessageDisplayManager.Instance.ShowMessage(
|
|
77
|
+
"ErrorHandelingTest CoroutineErrorTest_ShouldFail throwing expected errors wait 1");
|
|
78
|
+
yield return new WaitForSeconds(1); // Simulate some asynchronous behavior
|
|
79
|
+
MessageDisplayManager.Instance.ShowMessage(
|
|
80
|
+
"ErrorHandelingTest CoroutineErrorTest_ShouldFail throwing expected errors wait 0");
|
|
81
|
+
throw new System.Exception(
|
|
82
|
+
"ErrorHandelingTest CoroutineErrorTest_ShouldFail: This is an coroutine test that throws an exception.");
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Dummy test that runs async (PlayMode)
|
|
86
|
+
[UnityTest]
|
|
87
|
+
public async Task AsyncTest(Func<bool> shouldStop)
|
|
88
|
+
{
|
|
89
|
+
Debug.Log("ErrorHandelingTest AsyncTest: This is an asynchronous test.");
|
|
90
|
+
MessageDisplayManager.Instance.ShowMessage("ErrorHandelingTest AsyncTest wait for 1");
|
|
91
|
+
await Task.Delay(1000); // Simulate some asynchronous behavior
|
|
92
|
+
MessageDisplayManager.Instance.ShowMessage("ErrorHandelingTest AsyncTest wait for 0");
|
|
93
|
+
Assert.IsTrue(true); // Dummy assertion
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Dummy test that runs async and throws an exception (PlayMode)
|
|
97
|
+
[UnityTest]
|
|
98
|
+
public async Task AsyncErrorTest_ShouldFail(Func<bool> shouldStop)
|
|
99
|
+
{
|
|
100
|
+
Debug.Log("ErrorHandelingTest AsyncErrorTest_ShouldFail: This is an asynchronous test.");
|
|
101
|
+
MessageDisplayManager.Instance.ShowMessage("ErrorHandelingTest AsyncErrorTest_ShouldFail wait for 1");
|
|
102
|
+
await Task.Delay(1000); // Simulate some asynchronous behavior
|
|
103
|
+
MessageDisplayManager.Instance.ShowMessage("ErrorHandelingTest AsyncErrorTest_ShouldFail wait for 0");
|
|
104
|
+
throw new System.Exception(
|
|
105
|
+
"ErrorHandelingTest AsyncErrorTest_ShouldFail: This is an async test that throws an exception.");
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
#if UNITASK_PRESENT
|
|
109
|
+
|
|
110
|
+
/// <summary>
|
|
111
|
+
/// Dummy test that runs a UniTask (PlayMode).
|
|
112
|
+
/// </summary>
|
|
113
|
+
[UnityTest]
|
|
114
|
+
public async UniTask UniTaskTest(Func<bool> shouldStop)
|
|
115
|
+
{
|
|
116
|
+
Debug.Log("ErrorHandelingTest UniTaskTest: This is an UniTask test.");
|
|
117
|
+
MessageDisplayManager.Instance.ShowMessage("ErrorHandelingTest UniTask wait for 1");
|
|
118
|
+
await UniTask.Delay(1000); // Simulate async behavior
|
|
119
|
+
MessageDisplayManager.Instance.ShowMessage("ErrorHandelingTest UniTask wait for 0");
|
|
120
|
+
Assert.IsTrue(true); // Dummy assertion
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/// <summary>
|
|
124
|
+
/// Dummy test that runs asynchronously and throws an exception (PlayMode).
|
|
125
|
+
/// </summary>
|
|
126
|
+
[UnityTest]
|
|
127
|
+
public async UniTask UniTaskErrorTest_ShouldFail(Func<bool> shouldStop)
|
|
128
|
+
{
|
|
129
|
+
Debug.Log("ErrorHandelingTest UniTaskErrorTest_ShouldFail: This is an UniTask test.");
|
|
130
|
+
MessageDisplayManager.Instance.ShowMessage("ErrorHandelingTest UniTaskErrorTest_ShouldFail wait for 1");
|
|
131
|
+
await UniTask.Delay(1000); // Simulate async behavior
|
|
132
|
+
MessageDisplayManager.Instance.ShowMessage("ErrorHandelingTest UniTaskErrorTest_ShouldFail wait for 0");
|
|
133
|
+
throw new Exception("This is an UniTask test that throws an exception.");
|
|
134
|
+
}
|
|
135
|
+
#endif
|
|
136
|
+
|
|
137
|
+
/// <summary>
|
|
138
|
+
/// Dummy test that runs a Unity Awaitable (Unity 6+).
|
|
139
|
+
/// </summary>
|
|
140
|
+
[UnityTest]
|
|
141
|
+
public async Awaitable AwaitableTest(Func<bool> shouldStop)
|
|
142
|
+
{
|
|
143
|
+
Debug.Log("ErrorHandelingTest AwaitableTest: This is an Awaitable test.");
|
|
144
|
+
MessageDisplayManager.Instance.ShowMessage("ErrorHandelingTest Awaitable wait for 1");
|
|
145
|
+
await Awaitable.WaitForSecondsAsync(1f); // Simulate async behavior
|
|
146
|
+
MessageDisplayManager.Instance.ShowMessage("ErrorHandelingTest Awaitable wait for 0");
|
|
147
|
+
Assert.IsTrue(true); // Dummy assertion
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/// <summary>
|
|
151
|
+
/// Dummy test that runs an Awaitable and throws an exception.
|
|
152
|
+
/// </summary>
|
|
153
|
+
[UnityTest]
|
|
154
|
+
public async Awaitable AwaitableErrorTest_ShouldFail(Func<bool> shouldStop)
|
|
155
|
+
{
|
|
156
|
+
Debug.Log("ErrorHandelingTest AwaitableErrorTest_ShouldFail: This is an Awaitable test.");
|
|
157
|
+
MessageDisplayManager.Instance.ShowMessage("ErrorHandelingTest AwaitableErrorTest_ShouldFail wait for 1");
|
|
158
|
+
await Awaitable.WaitForSecondsAsync(1f); // Simulate async behavior
|
|
159
|
+
MessageDisplayManager.Instance.ShowMessage("ErrorHandelingTest AwaitableErrorTest_ShouldFail wait for 0");
|
|
160
|
+
throw new Exception("This is an Awaitable test that throws an exception.");
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// Regular teardown, called after each individual test
|
|
164
|
+
[TearDown]
|
|
165
|
+
public void TearDown()
|
|
166
|
+
{
|
|
167
|
+
Debug.Log("ErrorHandelingTest TearDown: Called after each test.");
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// One-time teardown, called once after all tests in this class
|
|
171
|
+
[OneTimeTearDown]
|
|
172
|
+
public void OneTimeTearDown()
|
|
173
|
+
{
|
|
174
|
+
Debug.Log("ErrorHandelingTest OneTimeTearDown: Called once after all tests.");
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|