Skip to content
This repository was archived by the owner on Dec 10, 2025. It is now read-only.

Commit 6f2f918

Browse files
committed
Extend tests for extensions throwing exceptions while loading
1 parent 151abde commit 6f2f918

File tree

3 files changed

+34
-4
lines changed

3 files changed

+34
-4
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// ***********************************************************************
2+
// Copyright (c) Charlie Poole and TestCentric contributors.
3+
// Licensed under the MIT License. See LICENSE file in root directory.
4+
// ***********************************************************************
5+
6+
using System;
7+
using TestCentric.Extensibility;
8+
9+
namespace TestCentric.Engine.Extensibility
10+
{
11+
[Extension(Enabled = true)]
12+
public class FailingTestEventListener : ITestEventListener
13+
{
14+
public FailingTestEventListener()
15+
{
16+
throw new InvalidOperationException();
17+
}
18+
19+
public void OnTestEvent(string text)
20+
{
21+
throw new System.NotImplementedException();
22+
}
23+
}
24+
}

src/testcentric.extensibility.tests/ExtensionManagerTestBase.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ class ThisIsNotAnExtensionPoint { }
129129
static string[] KnownExtensionTypeNames = new[] {
130130
"TestCentric.Engine.Extensibility.FakeAgentLauncher",
131131
"TestCentric.Engine.Extensibility.FakeTestEventListener",
132-
"NUnit.Engine.Extensibility.FakeProjectLoader"
132+
"NUnit.Engine.Extensibility.FakeProjectLoader",
133+
"TestCentric.Engine.Extensibility.FailingTestEventListener"
133134
};
134135

135136
[Test]

src/testcentric.extensibility.tests/ExtensionManager_NewApi.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44
// ***********************************************************************
55

66
using NUnit.Framework;
7-
using System;
8-
using System.Collections.Generic;
97
using System.Linq;
10-
using System.Text;
8+
using System.Reflection;
9+
using TestCentric.Engine;
1110

1211
namespace TestCentric.Extensibility
1312
{
@@ -37,5 +36,11 @@ public void CreateManager()
3736
ExtensionManager.FindExtensions(THIS_ASSEMBLY_DIRECTORY);
3837
Assert.That(ExtensionManager.Extensions.Count, Is.GreaterThan(0), "No Extensions were found");
3938
}
39+
40+
[Test]
41+
public void GetExtensions_ExtensionThrowsExceptiongWhileLoading()
42+
{
43+
Assert.Throws<TargetInvocationException>(() => ExtensionManager.GetExtensions<ITestEventListener>().ToList());
44+
}
4045
}
4146
}

0 commit comments

Comments
 (0)