private static MethodBase GetUnitTestMethod() { var frames = new StackTrace().GetFrames(); if (frames == null) { throw new Exception("Unable to get the StackTrace"); } return frames.Reverse(). // Stacks are LIFO, Reverse to start at the bottom. Select(frame => frame.GetMethod()). FirstOrDefault(method => method.GetCustomAttributes(false).Any(o => o.GetType() == TestSettings.TestFrameworkProvider.Value.TestMethodAttributeType)); }