Skip to content

Commit 2aa2221

Browse files
committed
Output exceptions
1 parent c10e449 commit 2aa2221

File tree

1 file changed

+25
-11
lines changed

1 file changed

+25
-11
lines changed

Source/Editor/TestRunner.cs

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class TestRunner : EditorPlugin
2727
Version = new Version(1, 1),
2828
RepositoryUrl = "https://github.com/FlaxCommunityProjects/FlaxUnitTesting"
2929
};
30-
30+
3131
public override void InitializeEditor()
3232
{
3333
base.InitializeEditor();
@@ -94,16 +94,23 @@ public static void RunTests()
9494
catch (TargetInvocationException e)
9595
{
9696
if (!(e.InnerException is SuccessException))
97+
{
9798
failed = true;
98-
}
99-
catch (Exception e)
100-
{
101-
failed = true;
99+
Debug.LogException(e.InnerException);
100+
}
102101
}
103102
finally
104103
{
105104
afterEach?.Invoke(instance, null);
106-
Debug.Log($"Test '{suite.Name} {testMethod.Name}' finished with " + (failed ? "Error" : "Success"));
105+
string message = $"Test '{suite.Name} {testMethod.Name}' finished with " + (failed ? "Error" : "Success");
106+
if (failed)
107+
{
108+
Debug.LogError(message);
109+
}
110+
else
111+
{
112+
Debug.Log(message);
113+
}
107114
}
108115
}
109116
else
@@ -123,11 +130,9 @@ public static void RunTests()
123130
catch (TargetInvocationException e)
124131
{
125132
if (!(e.InnerException is SuccessException))
133+
{
126134
failed = true;
127-
}
128-
catch (Exception e)
129-
{
130-
failed = true;
135+
}
131136
}
132137
finally
133138
{
@@ -138,7 +143,16 @@ public static void RunTests()
138143
}
139144
}
140145

141-
Debug.Log($"Test '{suite.Name} {testMethod.Name}' finished with {successCount}/{testCases.Count()} successfull test cases.");
146+
int testCount = testCases.Count();
147+
string message = $"Test '{suite.Name} {testMethod.Name}' finished with {successCount}/{testCount} successfull test cases.";
148+
if (successCount < testCount)
149+
{
150+
Debug.LogError(message);
151+
}
152+
else
153+
{
154+
Debug.Log(message);
155+
}
142156
}
143157
}
144158

0 commit comments

Comments
 (0)