diff options
author | Manish Sinha <manish.sinha@xamarin.com> | 2015-05-27 21:14:47 +0300 |
---|---|---|
committer | Manish Sinha <manish.sinha@xamarin.com> | 2015-05-27 21:35:54 +0300 |
commit | f139c3b10ad6c2b79253b5cbc727acacebc56945 (patch) | |
tree | 19cb638d8b709cc568a797c9bf9095f732b86c92 /main/tests/UserInterfaceTests/UITestBase.cs | |
parent | abbdf232b394510eeea9263e166a08b972fbf8e4 (diff) |
[UITest] Save Ide.log for failed tests and delete screenshots for passed tests
As Alan suggested, it would be wise to only deal with data related
to failed tests. So in this change, we check if the test has passed,
if passed then we delete the screenshot foldet for that test.
Before XS starts, we set the Log path and level, then in test teardown
we check if the test passed, if passed then we delete the log
In the FixtureTearDown we delete empty directories such that after
the test finishes, we are left with screenshots and logs of only
failed tests
Diffstat (limited to 'main/tests/UserInterfaceTests/UITestBase.cs')
-rw-r--r-- | main/tests/UserInterfaceTests/UITestBase.cs | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/main/tests/UserInterfaceTests/UITestBase.cs b/main/tests/UserInterfaceTests/UITestBase.cs index 5674ebfe90..501ba10b07 100644 --- a/main/tests/UserInterfaceTests/UITestBase.cs +++ b/main/tests/UserInterfaceTests/UITestBase.cs @@ -28,6 +28,7 @@ using System.IO; using NUnit.Framework; using MonoDevelop.Components.AutoTest; using System; +using System.Linq; namespace UserInterfaceTests { @@ -35,10 +36,14 @@ namespace UserInterfaceTests public abstract class UITestBase { string projectScreenshotFolder; + string currentWorkingDirectory; + string ideLogPath; int testScreenshotIndex; public string ScreenshotsPath { get; private set; } + public string CurrentXSIdeLog { get; private set; } + public AutoTestClientSession Session { get { return TestService.Session; } } @@ -50,12 +55,25 @@ namespace UserInterfaceTests protected UITestBase (string mdBinPath) { MonoDevelopBinPath = mdBinPath; + currentWorkingDirectory = Directory.GetCurrentDirectory (); + } + + [TestFixtureSetUp] + public virtual void FixtureSetup () + { InitializeScreenShotPath (); + ideLogPath = Path.Combine (currentWorkingDirectory, "Idelogs"); + if (!Directory.Exists (ideLogPath)) + Directory.CreateDirectory (ideLogPath); } [SetUp] public virtual void SetUp () { + CurrentXSIdeLog = Path.Combine (ideLogPath,string.Format ("{0}.Ide.log", TestContext.CurrentContext.Test.FullName) ); + Environment.SetEnvironmentVariable ("MONODEVELOP_LOG_FILE", CurrentXSIdeLog); + Environment.SetEnvironmentVariable ("MONODEVELOP_FILE_LOG_LEVEL", "All"); + TestService.StartSession (MonoDevelopBinPath); TestService.Session.DebugObject = new UITestDebug (); } @@ -65,12 +83,27 @@ namespace UserInterfaceTests { OnCleanUp (); TestService.EndSession (); + + if (TestContext.CurrentContext.Result.Status == TestStatus.Passed) { + if (Directory.Exists (projectScreenshotFolder)) + Directory.Delete (projectScreenshotFolder, true); + File.Delete (CurrentXSIdeLog); + } + } + + [TestFixtureTearDown] + public virtual void FixtureTearDown () + { + if (!Directory.EnumerateFileSystemEntries (ScreenshotsPath).Any ()) + Directory.Delete (ScreenshotsPath, true); + + if (!Directory.EnumerateFileSystemEntries (ideLogPath).Any ()) + Directory.Delete (ideLogPath, true); } void InitializeScreenShotPath () { - var pictureFolderName = Directory.GetCurrentDirectory (); - ScreenshotsPath = Path.Combine (pictureFolderName, "Screenshots", GetType ().Name); + ScreenshotsPath = Path.Combine (currentWorkingDirectory, "Screenshots", GetType ().Name); if (Directory.Exists (ScreenshotsPath)) { var lastAccess = Directory.GetLastAccessTime (ScreenshotsPath).ToString ("u").Replace (' ', '-').Replace (':', '-'); var newLocation = string.Format ("{0}-{1}", ScreenshotsPath, lastAccess); |