Skip to content

Commit

Permalink
Log test start/stop times (#17675)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbanni authored Sep 27, 2023
1 parent 9895399 commit 60683e0
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/Controls/tests/UITests/Tests/CoreGalleryBasePageTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ protected override void FixtureSetup()
}
catch (Exception e)
{
TestContext.Error.WriteLine($">>>>> The FixtureSetup threw an exception. Attempt {retries}/{SetupMaxRetries}.{Environment.NewLine}Exception details: {e}");
TestContext.Error.WriteLine($">>>>> {DateTime.Now} The FixtureSetup threw an exception. Attempt {retries}/{SetupMaxRetries}.{Environment.NewLine}Exception details: {e}");
if (retries++ < SetupMaxRetries)
{
Reset();
Expand All @@ -43,7 +43,7 @@ protected override void FixtureTeardown()
catch (Exception e)
{
var name = TestContext.CurrentContext.Test.MethodName ?? TestContext.CurrentContext.Test.Name;
TestContext.Error.WriteLine($">>>>> The FixtureTeardown threw an exception during {name}.{Environment.NewLine}Exception details: {e}");
TestContext.Error.WriteLine($">>>>> {DateTime.Now} The FixtureTeardown threw an exception during {name}.{Environment.NewLine}Exception details: {e}");
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/Controls/tests/UITests/Tests/Issues/_IssuesUITest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ protected override void FixtureSetup()
}
catch (Exception e)
{
TestContext.Error.WriteLine($">>>>> The FixtureSetup threw an exception. Attempt {retries}/{SetupMaxRetries}.{Environment.NewLine}Exception details: {e}");
TestContext.Error.WriteLine($">>>>> {DateTime.Now} The FixtureSetup threw an exception. Attempt {retries}/{SetupMaxRetries}.{Environment.NewLine}Exception details: {e}");
if (retries++ < SetupMaxRetries)
{
Reset();
Expand All @@ -45,7 +45,7 @@ protected override void FixtureTeardown()
catch (Exception e)
{
var name = TestContext.CurrentContext.Test.MethodName ?? TestContext.CurrentContext.Test.Name;
TestContext.Error.WriteLine($">>>>> The FixtureTeardown threw an exception during {name}.{Environment.NewLine}Exception details: {e}");
TestContext.Error.WriteLine($">>>>> {DateTime.Now} The FixtureTeardown threw an exception during {name}.{Environment.NewLine}Exception details: {e}");
}
}

Expand Down
26 changes: 24 additions & 2 deletions src/Controls/tests/UITests/Tests/UITestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,31 @@ public UITestBase(TestDevice device)
_visualTestContext = new VisualTestContext();
}

protected virtual void FixtureSetup() { }
[SetUp]
public void RecordTestSetup()
{
var name = TestContext.CurrentContext.Test.MethodName ?? TestContext.CurrentContext.Test.Name;
TestContext.Progress.WriteLine($">>>>> {DateTime.Now} {name} Start");
}

[TearDown]
public void RecordTestTeardown()
{
var name = TestContext.CurrentContext.Test.MethodName ?? TestContext.CurrentContext.Test.Name;
TestContext.Progress.WriteLine($">>>>> {DateTime.Now} {name} Stop");
}

protected virtual void FixtureTeardown() { }
protected virtual void FixtureSetup()
{
var name = TestContext.CurrentContext.Test.MethodName ?? TestContext.CurrentContext.Test.Name;
TestContext.Progress.WriteLine($">>>>> {DateTime.Now} {nameof(FixtureSetup)} for {name}");
}

protected virtual void FixtureTeardown()
{
var name = TestContext.CurrentContext.Test.MethodName ?? TestContext.CurrentContext.Test.Name;
TestContext.Progress.WriteLine($">>>>> {DateTime.Now} {nameof(FixtureTeardown)} for {name}");
}

[TearDown]
public void UITestBaseTearDown()
Expand Down
4 changes: 2 additions & 2 deletions src/TestUtils/src/TestUtils.Appium.UITests/AppiumContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public UITestContext CreateUITestContext(TestConfig testConfig)
{
if (_server == null || !_server.IsRunning)
{
TestContext.Error.WriteLine($">>>>> Server was not running when calling {nameof(CreateUITestContext)}, starting it ourselves...");
TestContext.Error.WriteLine($">>>>> {DateTime.Now} Server was not running when calling {nameof(CreateUITestContext)}, starting it ourselves...");
CreateAndStartServer();
}
}
Expand Down Expand Up @@ -109,7 +109,7 @@ public UITestContext CreateUITestContext(TestConfig testConfig)
// Default command timeout is 60 seconds when executing the NewSessionCommand
if (retries++ < 10)
{
TestContext.Error.WriteLine($">>>>> Retrying to create the driver, attempt #{retries}");
TestContext.Error.WriteLine($">>>>> {DateTime.Now} Retrying to create the driver, attempt #{retries}");
}
else
{
Expand Down

0 comments on commit 60683e0

Please sign in to comment.