Skip to content

Commit

Permalink
More changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubch1 committed Jun 2, 2020
1 parent e23d24d commit 6189eb0
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ private void ProcessRequests(ITestRequestManager testRequestManager)
break;
}

case MessageType.MultiTestRunsFinalization:
case MessageType.MultiTestRunsFinalizationStart:
{
var multiTestRunsFinalizationPayload =
this.communicationManager.DeserializePayload<MultiTestRunsFinalizationPayload>(message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,17 @@ public static class MessageType
/// <summary>
/// Multi test runs finalization
/// </summary>
public const string MultiTestRunsFinalization = "TestExecution.MultiTestRunsFinalization";
public const string MultiTestRunsFinalizationStart = "MultiTestRunsFinalization.Start";

/// <summary>
/// Multi test runs finalization callback
/// </summary>
public const string MultiTestRunsFinalizationComplete = "TestExecution.MultiTestRunsFinalizationComplete";
public const string MultiTestRunsFinalizationComplete = "MultiTestRunsFinalization.Complete";

/// <summary>
/// Cancel multi test runs finalization
/// </summary>
public const string MultiTestRunsFinalizationCancel = "MultiTestRunsFinalization.Cancel";

/// <summary>
/// Extensions Initialization
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ public void OnMessageReceived(object sender, MessageReceivedEventArgs messageRec
break;
}

case MessageType.MultiTestRunsFinalization:
case MessageType.MultiTestRunsFinalizationStart:
{
EqtTrace.Info("Multi test runs finalization started.");
var multiTestRunsFinalizationEventsHandler = new MultiTestRunsFinalizationEventsHandler(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,10 @@ internal interface ITranslationLayerRequestSender : IDisposable
/// <param name="attachments">List of attachements</param>
/// <param name="multiTestRunsFinalizationCompleteEventsHandler"></param>
void FinalizeMultiTestRuns(ICollection<AttachmentSet> attachments, IMultiTestRunsFinalizationEventsHandler multiTestRunsFinalizationCompleteEventsHandler);

/// <summary>
/// Cancels multi test runs finalization
/// </summary>
void CancelMultiTestRunsFinalization();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,10 @@ public interface IVsTestConsoleWrapper2 : IVsTestConsoleWrapper
/// <param name="attachments">List of attachements</param>
/// <param name="multiTestRunsFinalizationCompleteEventsHandler">EventHandler to receive session complete event</param>
void FinalizeMultiTestRuns(ICollection<AttachmentSet> attachments, IMultiTestRunsFinalizationEventsHandler multiTestRunsFinalizationCompleteEventsHandler);

/// <summary>
/// Cancel last multi test runs finalization
/// </summary>
void CancelMultiTestRunsFinalization();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,16 @@ public void FinalizeMultiTestRuns(ICollection<AttachmentSet> attachments, IMulti
this.SendMessageAndListenAndReportAttachements(attachments, testSessionEventsHandler);
}

/// <inheritdoc/>
public void CancelMultiTestRunsFinalization()
{
if (EqtTrace.IsInfoEnabled)
{
EqtTrace.Info("VsTestConsoleRequestSender.CancelMultiTestRunsFinalization: Canceling multi test runs finalization.");
}
this.communicationManager.SendMessage(MessageType.MultiTestRunsFinalizationCancel);
}

/// <summary>
/// Closes the communication channel
/// </summary>
Expand Down Expand Up @@ -739,7 +749,7 @@ private void SendMessageAndListenAndReportAttachements(ICollection<AttachmentSet
{
Attachments = attachments
};
this.communicationManager.SendMessage(MessageType.MultiTestRunsFinalization, payload);
this.communicationManager.SendMessage(MessageType.MultiTestRunsFinalizationStart, payload);
var isMultiTestRunsFinalizationComplete = false;

// Cycle through the messages that the vstest.console sends.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,12 @@ public void FinalizeMultiTestRuns(ICollection<AttachmentSet> attachments, IMulti
this.requestSender.FinalizeMultiTestRuns(attachments, testSessionEventsHandler);
}

/// <inheritdoc/>
public void CancelMultiTestRunsFinalization()
{
throw new System.NotImplementedException();
}

#endregion

private void EnsureInitialized()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ public void HandleTestRunComplete(
this.TestResults.AddRange(lastChunkArgs.NewTestResults);
}

if(runContextAttachments != null)
if (testRunCompleteArgs.AttachmentSets != null)
{
this.Attachments.AddRange(runContextAttachments);
this.Attachments.AddRange(testRunCompleteArgs.AttachmentSets);
}

this.Metrics = testRunCompleteArgs.Metrics;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,47 +39,24 @@ public void Cleanup()
this.vstestConsoleWrapper?.EndSession();
}

//[TestMethod]
//[NetFullTargetFrameworkDataSource]
//[NetCoreTargetFrameworkDataSource]
//public void RunAllTests(RunnerInfo runnerInfo)
//{
// AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo);
// this.Setup();

// this.vstestConsoleWrapper.RunTests(this.GetTestAssemblies().Take(1), this.GetCodeCoverageRunSettings(), this.runEventHandler);
// this.vstestConsoleWrapper.RunTests(this.GetTestAssemblies().Skip(1), this.GetCodeCoverageRunSettings(), this.runEventHandler);

// // Assert
// Assert.AreEqual(6, this.runEventHandler.TestResults.Count);
// Assert.AreEqual(2, this.runEventHandler.Attachments.Count);
// Assert.AreEqual(2, this.runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Passed));
// Assert.AreEqual(2, this.runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Failed));
// Assert.AreEqual(2, this.runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Skipped));

// this.vstestConsoleWrapper.FinalizeMultiTestRuns(runEventHandler.Attachments, multiTestRunsFinalizationEventHandler);
// Assert.AreEqual(1, this.multiTestRunsFinalizationEventHandler.Attachments.Count);
//}

[TestMethod]
public void RunAllTests()
[NetFullTargetFrameworkDataSource]
[NetCoreTargetFrameworkDataSource]
public void FinalizeMultiTestRuns(RunnerInfo runnerInfo)
{
RunnerInfo runnerInfo = new RunnerInfo(AcceptanceTestBase.DesktopTargetFramework, AcceptanceTestBase.DesktopTargetFramework);
AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo);
this.Setup();

this.vstestConsoleWrapper.RunTests(this.GetTestAssemblies().Take(1), this.GetCodeCoverageRunSettings(), this.runEventHandler);
//this.vstestConsoleWrapper.RunTests(this.GetTestAssemblies().Skip(1), this.GetCodeCoverageRunSettings(), this.runEventHandler);
this.vstestConsoleWrapper.RunTests(this.GetTestAssemblies().Skip(1), this.GetCodeCoverageRunSettings(), this.runEventHandler);

Assert.AreEqual(6, this.runEventHandler.TestResults.Count);
Assert.AreEqual(2, this.runEventHandler.Attachments.Count);

this.vstestConsoleWrapper.FinalizeMultiTestRuns(runEventHandler.Attachments, multiTestRunsFinalizationEventHandler);

// Assert
Assert.AreEqual(3, this.runEventHandler.TestResults.Count);
Assert.AreEqual(1, this.runEventHandler.Attachments.Count);
//Assert.AreEqual(2, this.runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Passed));
//Assert.AreEqual(2, this.runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Failed));
//Assert.AreEqual(2, this.runEventHandler.TestResults.Count(t => t.Outcome == TestOutcome.Skipped));

//this.vstestConsoleWrapper.FinalizeMultiTestRuns(runEventHandler.Attachments, multiTestRunsFinalizationEventHandler);
//Assert.AreEqual(1, this.multiTestRunsFinalizationEventHandler.Attachments.Count);
Assert.AreEqual(testEnvironment.RunnerFramework.Equals(IntegrationTestBase.DesktopRunnerFramework) ? 1 : 2, this.multiTestRunsFinalizationEventHandler.Attachments.Count);
}

[TestMethod]
Expand All @@ -92,7 +69,13 @@ public void EndSessionShouldEnsureVstestConsoleProcessDies(RunnerInfo runnerInfo
AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo);
this.Setup();

this.vstestConsoleWrapper.RunTests(this.GetTestAssemblies(), this.GetDefaultRunSettings(), this.runEventHandler);
this.vstestConsoleWrapper.RunTests(this.GetTestAssemblies().Take(1), this.GetCodeCoverageRunSettings(), this.runEventHandler);
this.vstestConsoleWrapper.RunTests(this.GetTestAssemblies().Skip(1), this.GetCodeCoverageRunSettings(), this.runEventHandler);

Assert.AreEqual(6, this.runEventHandler.TestResults.Count);
Assert.AreEqual(2, this.runEventHandler.Attachments.Count);

this.vstestConsoleWrapper.FinalizeMultiTestRuns(runEventHandler.Attachments, multiTestRunsFinalizationEventHandler);
this.vstestConsoleWrapper?.EndSession();

// Assert
Expand Down

0 comments on commit 6189eb0

Please sign in to comment.