File tree Expand file tree Collapse file tree 2 files changed +34
-6
lines changed Expand file tree Collapse file tree 2 files changed +34
-6
lines changed Original file line number Diff line number Diff 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 {
Original file line number Diff line number Diff line change 1- using FlaxEditor ;
1+ using FlaxEditor ;
22using FlaxEditor . GUI ;
33using FlaxEngine ;
44using 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 ) ;
You can’t perform that action at this time.
0 commit comments