Skip to content

Commit 189cae8

Browse files
committed
Bugfixes
1 parent b380713 commit 189cae8

File tree

2 files changed

+34
-6
lines changed

2 files changed

+34
-6
lines changed

Source/Assert.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,20 @@ namespace FlaxCommunity.UnitTesting
66
/// Special type of exception that is used to terminate the test case early <seealso cref="Assert.Pass"/>
77
/// </summary>
88
/// <seealso cref="System.Exception" />
9-
public class SuccessException : Exception { }
9+
public class SuccessException : Exception
10+
{
11+
public SuccessException()
12+
{
13+
}
14+
15+
public SuccessException(string message) : base(message)
16+
{
17+
}
18+
19+
public SuccessException(string message, Exception innerException) : base(message, innerException)
20+
{
21+
}
22+
}
1023

1124
public static class Assert
1225
{

Source/Editor/TestRunner.cs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using FlaxEditor;
1+
using FlaxEditor;
22
using FlaxEditor.GUI;
33
using FlaxEngine;
44
using System;
@@ -36,6 +36,13 @@ public override void InitializeEditor()
3636

3737
_mmBtn = Editor.UI.MainMenu.AddButton("Unit Tests");
3838
_mmBtn.ContextMenu.AddButton("Run unit tests").Clicked += RunTests;
39+
FlaxEditor.Scripting.ScriptsBuilder.ScriptsReloadBegin += ScriptsBuilder_ScriptsReloadBegin;
40+
}
41+
42+
private void ScriptsBuilder_ScriptsReloadBegin()
43+
{
44+
// Clear type information as per warning https://docs.flaxengine.com/manual/scripting/plugins/index.html
45+
_suites.Clear();
3946
}
4047

4148
public override void Deinitialize()
@@ -86,11 +93,15 @@ public static void RunTests()
8693
{
8794
testMethod?.Invoke(instance, null);
8895
}
89-
catch (Exception e)
96+
catch (TargetInvocationException e)
9097
{
91-
if (e.GetType() != typeof(SuccessException))
98+
if (!(e.InnerException is SuccessException))
9299
failed = true;
93100
}
101+
catch (Exception e)
102+
{
103+
failed = true;
104+
}
94105
finally
95106
{
96107
afterEach?.Invoke(instance, null);
@@ -111,11 +122,15 @@ public static void RunTests()
111122
if (testCase.ExpectedResult != null)
112123
failed = !testCase.ExpectedResult.Equals(result);
113124
}
114-
catch (Exception e)
125+
catch (TargetInvocationException e)
115126
{
116-
if (e.GetType() != typeof(SuccessException))
127+
if (!(e.InnerException is SuccessException))
117128
failed = true;
118129
}
130+
catch (Exception e)
131+
{
132+
failed = true;
133+
}
119134
finally
120135
{
121136
afterEach?.Invoke(instance, null);

0 commit comments

Comments
 (0)