Skip to content

Commit 442db50

Browse files
committed
Simplfy finding test page attribute.
1 parent 3012a7f commit 442db50

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

UITests/UITests.Tests.Shared/UITestBase.cs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -104,22 +104,12 @@ public async Task TestInitialize()
104104
var theClassName = TestContext.FullyQualifiedTestClassName;
105105
#endif
106106
var currentlyRunningClassType = AppDomain.CurrentDomain.GetAssemblies().SelectMany(a => a.GetTypes()).FirstOrDefault(f => f.FullName == theClassName);
107-
if (!(Type.GetType(theClassName) is Type type))
108-
{
109-
Verify.Fail("Type is null. TestClassName : " + theClassName);
110-
return;
111-
}
112-
113-
if (!(type.GetMethod(testName) is MethodInfo method))
114-
{
115-
Verify.Fail("Mothod is null. TestClassName : " + theClassName + " Testname: " + testName);
116-
return;
117-
}
118107

119-
if (!(method.GetCustomAttribute(typeof(TestPageAttribute), true) is TestPageAttribute attribute))
108+
if (!(Type.GetType(theClassName) is Type type
109+
&& type.GetMethod(testName) is MethodInfo method
110+
&& method.GetCustomAttribute(typeof(TestPageAttribute), true) is TestPageAttribute attribute))
120111
{
121-
Verify.Fail("Attribute is null. TestClassName : " + theClassName);
122-
return;
112+
throw new Exception("Could not find " + nameof(TestPageAttribute) + " on test method.");
123113
}
124114

125115
var pageName = attribute.XamlFile;

0 commit comments

Comments
 (0)