6
6
using System . Linq ;
7
7
using System . Reflection ;
8
8
using NUnit . Framework ;
9
+ using NUnit . Framework . Internal ;
9
10
using Umbraco . Cms . Core . Exceptions ;
10
11
11
12
namespace Umbraco . Cms . Tests . Common . Testing
12
13
{
13
14
public abstract class TestOptionAttributeBase : Attribute
14
15
{
16
+ [ Obsolete ( "This is not used anymore - Test classes are found using nunit helpers" ) ]
15
17
public static readonly List < Assembly > ScanAssemblies = new List < Assembly > ( ) ;
16
18
17
19
public static TOptions GetTestOptions < TOptions > ( MethodInfo method )
@@ -29,26 +31,8 @@ public static TOptions GetTestOptions<TOptions>()
29
31
where TOptions : TestOptionAttributeBase , new ( )
30
32
{
31
33
TestContext . TestAdapter test = TestContext . CurrentContext . Test ;
32
- var typeName = test . ClassName ;
33
34
var methodName = test . MethodName ;
34
-
35
- // This will only get types from whatever is already loaded in the app domain.
36
- var type = Type . GetType ( typeName , false ) ;
37
- if ( type == null )
38
- {
39
- // automatically add the executing and calling assemblies to the list to scan for this type
40
- var scanAssemblies = ScanAssemblies . Union ( new [ ] { Assembly . GetExecutingAssembly ( ) , Assembly . GetCallingAssembly ( ) } ) . ToList ( ) ;
41
-
42
- type = scanAssemblies
43
- . Select ( assembly => assembly . GetType ( typeName , false ) )
44
- . FirstOrDefault ( x => x != null ) ;
45
- if ( type == null )
46
- {
47
- throw new PanicException ( $ "Could not resolve the running test fixture from type name { typeName } .\n " +
48
- $ "To use base classes from Umbraco.Tests, add your test assembly to TestOptionAttributeBase.ScanAssemblies") ;
49
- }
50
- }
51
-
35
+ var type = TestExecutionContext . CurrentContext . TestObject . GetType ( ) ;
52
36
MethodInfo methodInfo = type . GetMethod ( methodName ) ; // what about overloads?
53
37
TOptions options = GetTestOptions < TOptions > ( methodInfo ) ;
54
38
return options ;
0 commit comments