public void Setup() { // Save a reference to the current Test's log in its TestContext TestContext.Set("log", ""); // Get the Test's custom Attributes IEnumerable <CustomAttributeData> customAttributeDatas = new StackTrace().GetFrame(1).GetMethod().CustomAttributes; // Log the custom Attributes Log.CustomAttributes(customAttributeDatas); // Write an end-line Log.WriteLine(); // Figure out the padding (if any) to prepend to the log line LogPadding logPadding = new LogPadding(new StackTrace().GetFrame(1).GetMethod().ReflectedType); // Logging - Before action StringBuilder sb = new StringBuilder(); sb.AppendLine(logPadding.Padding + "TestBase.Setup()"); sb.AppendLine(logPadding.InfoPadding + "[STACK] Caller: " + new StackTrace().GetFrame(1).GetMethod().ReflectedType + "." + new StackTrace().GetFrame(1).GetMethod().Name + "()"); Log.Write(sb.ToString()); // Perform the action try { // Create a WebDrvier session Session.Create(); // Set WebDriver's window to full screen AppBase.Maximize(); // Delete all cookies AppBase.DeleteAllCookies(); // Logging - After action success Log.Success(logPadding.Padding); } catch (Exception e) { // Logging - After action exception sb = Log.Exception(sb, e); // Fail current Test Assert.Fail(sb.ToString()); } finally { // Logging - After action Log.Finally(logPadding.Padding); } }
public void Setup() { // Save a reference to the current Test's log in its TestContext TestContext.Set("log", ""); // Log the test attributes of the current [Test] Log.StandardAttributes(); // Log Before Action Log.BeforeAction(); // Perform the action try { // Create a WebDrvier session Session.Create(); // Set WebDriver's window to full screen AppBase.Maximize(); // Delete all cookies AppBase.DeleteAllCookies(); // Logging - After action success Log.Success(); } catch (Exception e) { // Logging - After action exception Log.Failure(e.Message); // Fail current test Assert.Fail(e.Message); } finally { // Logging - After action Log.Finally(); } }