Skip to content

Commit

Permalink
Fix race conditions in acceptance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubch1 committed Jun 23, 2020
1 parent 303cee8 commit 676c02b
Showing 1 changed file with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,16 @@ public async Task TestRunWithCodeCoverageAndFinalization(RunnerInfo runnerInfo)
Assert.IsFalse(multiTestRunFinalizationEventHandler.CompleteArgs.IsCanceled);
Assert.IsNull(multiTestRunFinalizationEventHandler.CompleteArgs.Error);

Assert.AreEqual(testEnvironment.RunnerFramework.Equals(IntegrationTestBase.DesktopRunnerFramework) ? 2 : 0, multiTestRunFinalizationEventHandler.ProgressArgs.Count);
for (int i = 0; i < multiTestRunFinalizationEventHandler.ProgressArgs.Count; i++)
{
VisualStudio.TestPlatform.ObjectModel.Client.MultiTestRunFinalizationProgressEventArgs progressArgs = multiTestRunFinalizationEventHandler.ProgressArgs[i];
Assert.AreEqual(1, progressArgs.CurrentHandlerIndex);
Assert.AreEqual("datacollector://microsoft/CodeCoverage/2.0", progressArgs.CurrentHandlerUri.AbsoluteUri);
Assert.AreEqual(1, progressArgs.HandlersCount);
Assert.AreEqual(i == 0 ? 50 : 100, progressArgs.CurrentHandlerProgress);
if (multiTestRunFinalizationEventHandler.ProgressArgs.Count == 2)
{
Assert.AreEqual(i == 0 ? 50 : 100, progressArgs.CurrentHandlerProgress);
}
}

Assert.AreEqual("Completed", multiTestRunFinalizationEventHandler.CompleteArgs.Metrics[TelemetryDataConstants.FinalizationState]);
Expand Down Expand Up @@ -161,14 +163,16 @@ public async Task TestRunWithCodeCoverageAndFinalizationNoMetrics(RunnerInfo run
Assert.IsFalse(multiTestRunFinalizationEventHandler.CompleteArgs.IsCanceled);
Assert.IsNull(multiTestRunFinalizationEventHandler.CompleteArgs.Error);

Assert.AreEqual(testEnvironment.RunnerFramework.Equals(IntegrationTestBase.DesktopRunnerFramework) ? 2 : 0, multiTestRunFinalizationEventHandler.ProgressArgs.Count);
for (int i = 0; i < multiTestRunFinalizationEventHandler.ProgressArgs.Count; i++)
{
VisualStudio.TestPlatform.ObjectModel.Client.MultiTestRunFinalizationProgressEventArgs progressArgs = multiTestRunFinalizationEventHandler.ProgressArgs[i];
Assert.AreEqual(1, progressArgs.CurrentHandlerIndex);
Assert.AreEqual("datacollector://microsoft/CodeCoverage/2.0", progressArgs.CurrentHandlerUri.AbsoluteUri);
Assert.AreEqual(1, progressArgs.HandlersCount);
Assert.AreEqual(i == 0 ? 50 : 100, progressArgs.CurrentHandlerProgress);
if (multiTestRunFinalizationEventHandler.ProgressArgs.Count == 2)
{
Assert.AreEqual(i == 0 ? 50 : 100, progressArgs.CurrentHandlerProgress);
}
}

Assert.IsTrue(multiTestRunFinalizationEventHandler.CompleteArgs.Metrics.IsNullOrEmpty());
Expand Down Expand Up @@ -205,14 +209,17 @@ public async Task TestRunWithCodeCoverageAndFinalizationModuleDuplicated(RunnerI
Assert.IsFalse(multiTestRunFinalizationEventHandler.CompleteArgs.IsCanceled);
Assert.IsNull(multiTestRunFinalizationEventHandler.CompleteArgs.Error);

Assert.AreEqual(testEnvironment.RunnerFramework.Equals(IntegrationTestBase.DesktopRunnerFramework) ? 3 : 0, multiTestRunFinalizationEventHandler.ProgressArgs.Count);
for (int i = 0; i < multiTestRunFinalizationEventHandler.ProgressArgs.Count; i++)
{
VisualStudio.TestPlatform.ObjectModel.Client.MultiTestRunFinalizationProgressEventArgs progressArgs = multiTestRunFinalizationEventHandler.ProgressArgs[i];
Assert.AreEqual(1, progressArgs.CurrentHandlerIndex);
Assert.AreEqual("datacollector://microsoft/CodeCoverage/2.0", progressArgs.CurrentHandlerUri.AbsoluteUri);
Assert.AreEqual(1, progressArgs.HandlersCount);
Assert.AreEqual(i == 0 ? 33 : i == 1 ? 66 : 100, progressArgs.CurrentHandlerProgress);

if (multiTestRunFinalizationEventHandler.ProgressArgs.Count == 3)
{
Assert.AreEqual(i == 0 ? 33 : i == 1 ? 66 : 100, progressArgs.CurrentHandlerProgress);
}
}

Assert.AreEqual("Completed", multiTestRunFinalizationEventHandler.CompleteArgs.Metrics[TelemetryDataConstants.FinalizationState]);
Expand Down Expand Up @@ -279,14 +286,10 @@ public async Task TestRunWithCodeCoverageAndFinalizationCancelled(RunnerInfo run
Assert.AreEqual("datacollector://microsoft/CodeCoverage/2.0", progressArgs.CurrentHandlerUri.AbsoluteUri);
Assert.AreEqual(1, progressArgs.HandlersCount);

if (i == 5)
if (i == 0)
{
Assert.AreEqual(0, progressArgs.CurrentHandlerProgress);
}
else if (i == 15)
{
Assert.AreEqual(1, progressArgs.CurrentHandlerProgress);
}
}
}

Assert.AreEqual("Canceled", multiTestRunFinalizationEventHandler.CompleteArgs.Metrics[TelemetryDataConstants.FinalizationState]);
Expand Down

0 comments on commit 676c02b

Please sign in to comment.