diff options
author | Kyle White <kyle.white@xamarin.com> | 2015-09-24 22:11:30 +0300 |
---|---|---|
committer | Kyle White <kyle.white@xamarin.com> | 2015-09-26 00:26:23 +0300 |
commit | 6416c410df33180e9f348877b55bf3923d3d800c (patch) | |
tree | e7f7f0c06d218c0df67113ce1ee55968fb0dbd38 /main/tests/UserInterfaceTests/UITestBase.cs | |
parent | 37fbbf42f97c626e3d3617591ede9a611606d06a (diff) |
[UITest] Implement test log file and ReproStep method
Diffstat (limited to 'main/tests/UserInterfaceTests/UITestBase.cs')
-rw-r--r-- | main/tests/UserInterfaceTests/UITestBase.cs | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/main/tests/UserInterfaceTests/UITestBase.cs b/main/tests/UserInterfaceTests/UITestBase.cs index 1693f62e7d..146e5ae089 100644 --- a/main/tests/UserInterfaceTests/UITestBase.cs +++ b/main/tests/UserInterfaceTests/UITestBase.cs @@ -31,6 +31,8 @@ using System; using System.Collections.Generic; using Newtonsoft.Json; using System.Linq; +using MonoDevelop.Core.Logging; +using MonoDevelop.Core; namespace UserInterfaceTests { @@ -42,9 +44,10 @@ namespace UserInterfaceTests string currentTestResultFolder; string currentTestResultScreenshotFolder; - int testScreenshotIndex; + int testScreenshotIndex, reproStepIndex; protected readonly List<string> FoldersToClean = new List<string> (); + protected FileLogger Logger; public AutoTestClientSession Session { get { return TestService.Session; } @@ -70,6 +73,7 @@ namespace UserInterfaceTests public virtual void SetUp () { SetupTestResultFolder (); + SetupTestLogger (); SetupScreenshotsFolder (); SetupIdeLogFolder (); @@ -95,6 +99,8 @@ namespace UserInterfaceTests Assert.Inconclusive ("Xamarin Update is blocking the application focus"); } ValidateIdeLogMessages (); + LoggingService.RemoveLogger (Logger.Name); + Logger.Dispose (); } finally { var testStatus = TestContext.CurrentContext.Result.Status; if (testStatus != TestStatus.Passed) { @@ -144,6 +150,16 @@ namespace UserInterfaceTests Directory.CreateDirectory (currentTestResultFolder); } + void SetupTestLogger () + { + var currentTestLog = Path.Combine (currentTestResultFolder, string.Format ("{0}.Test.log.txt", TestContext.CurrentContext.Test.Name.ToPathSafeString ())); + Logger = new FileLogger (currentTestLog) { + Name = "UITestLogger", + EnabledLevel = EnabledLoggingLevel.All, + }; + LoggingService.AddLogger (Logger); + } + void SetupScreenshotsFolder () { testScreenshotIndex = 1; @@ -155,7 +171,7 @@ namespace UserInterfaceTests void SetupIdeLogFolder () { - var currentXSIdeLog = Path.Combine (currentTestResultFolder, string.Format ("{0}.Ide.log", TestContext.CurrentContext.Test.Name.Replace ('/','_').Replace ('\\','_'))); + var currentXSIdeLog = Path.Combine (currentTestResultFolder, string.Format ("{0}.Ide.log", TestContext.CurrentContext.Test.Name.ToPathSafeString ())); Environment.SetEnvironmentVariable ("MONODEVELOP_LOG_FILE", currentXSIdeLog); Environment.SetEnvironmentVariable ("MONODEVELOP_FILE_LOG_LEVEL", "UpToInfo"); } @@ -167,6 +183,17 @@ namespace UserInterfaceTests Session.TakeScreenshot (screenshotPath); } + protected void ReproStep (string stepDescription, params object[] info) + { + reproStepIndex++; + stepDescription = string.Format ("@Repro-Step-{0:D2}: {1}", reproStepIndex, stepDescription); + LoggingService.LogInfo (stepDescription); + foreach (var obj in info) { + if (obj != null) + LoggingService.LogInfo (string.Format("@Repro-Info-{0:D2}: {1}", reproStepIndex, obj.ToString ())); + } + } + protected virtual void OnCleanUp () { foreach (var folder in FoldersToClean) { |