Skip to content

Commit

Permalink
Communication layer cleanup (#43)
Browse files Browse the repository at this point in the history
* Initial Draft for Framework related changes.
- Fixed the Json serialization issues
- Added the Processor for Framework
- Fixed the tests
- Added new tests for Processor
* Fix unit tests for framework support.
* Clean json serialization in ObjectModel, TranslationLayer.

Json serialization doesn't use embedded type information. Removed dependency of OM on json.net. Fix #26.
Standardize property serialization for TestObject and derived objects. Derived objects don't need to mark
properties as serializable, this trims the data sent over the wire.
Properties in a TestObject are serialized in json as Properties array.
Remove any special handling of TestProperty values, these are always deserialized as string. A consumer may
write custom converters to interpret them. E.g. add a converter for KeyValuePair<string, string>[] data
required by traits.
* Move test projects to dotnet-test-mstest 1.1.1-preview.
* Use null values for TestProperty as-is during deserialization.
* Add guard for desktop assemblies in test property data. Fix a deserialization test issue.
* Add a string array converter for test properties. Add netcore framework type.
* Add datetime handling for JSON parsing. Use Utc and ISO date formats for all datetimes.
Use the same settings in product for json unit tests.
* Add VSTEST_RUNNER_DEBUG and VSTEST_HOST_DEBUG environment variables to allow
attach debugger to the runner and host processes.
* Update OM.nuspec since json.net is no longer a dependency.
  • Loading branch information
codito committed Sep 9, 2016
1 parent 4f07f20 commit 9907beb
Show file tree
Hide file tree
Showing 85 changed files with 2,647 additions and 1,121 deletions.
6 changes: 3 additions & 3 deletions src/Microsoft.TestPlatform.Client/TestPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ public IDiscoveryRequest CreateDiscoveryRequest(DiscoveryCriteria discoveryCrite
}

var runconfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(discoveryCriteria.RunSettings);
var testHostManager = this.TestEngine.GetDefaultTestHostManager(runconfiguration.TargetPlatform);

var testHostManager = this.TestEngine.GetDefaultTestHostManager(runconfiguration.TargetPlatform, runconfiguration.TargetFrameworkVersion);
var discoveryManager = this.TestEngine.GetDiscoveryManager();
discoveryManager.Initialize(testHostManager);

Expand All @@ -76,7 +76,7 @@ public ITestRunRequest CreateTestRunRequest(TestRunCriteria testRunCriteria)
}

var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(testRunCriteria.TestRunSettings);
var testHostManager = this.TestEngine.GetDefaultTestHostManager(runConfiguration.TargetPlatform);
var testHostManager = this.TestEngine.GetDefaultTestHostManager(runConfiguration.TargetPlatform, runConfiguration.TargetFrameworkVersion);

if (testRunCriteria.TestHostLauncher != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ public interface ITestEngine
/// </summary>
/// <param name="architecture">Architecture of the test run</param>
/// <returns>Launcher for the test host process</returns>
ITestHostManager GetDefaultTestHostManager(Architecture architecture);
ITestHostManager GetDefaultTestHostManager(Architecture architecture, Framework framework);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public interface ITestHostManager
/// <summary>
/// Sets a custom launcher
/// </summary>
/// <param name="customTestHostLauncher">Custom launcher to set</param>
void SetCustomLauncher(ITestHostLauncher customTestHostLauncher);
/// <param name="customLauncher">Custom launcher to set</param>
void SetCustomLauncher(ITestHostLauncher customLauncher);

/// <summary>
/// Launches the test host for discovery/execution.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@
namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.ClientProtocol
{
using System;
using System.Diagnostics;
using System.Runtime.Serialization;

using Newtonsoft.Json;

/// <summary>
/// Stores information about test execution context.
/// </summary>
Expand All @@ -17,7 +14,16 @@ public class TestExecutionContext
#region Constructors

/// <summary>
/// The constructor.
/// Initializes a new instance of the <see cref="TestExecutionContext"/> class.
/// </summary>
/// <remarks>This constructor doesn't perform any parameter validation, it is meant to be used for serialization."/></remarks>
public TestExecutionContext()
{
// Default constructor for Serialization.
}

/// <summary>
/// Initializes a new instance of the <see cref="TestExecutionContext"/> class.
/// </summary>
/// <param name="frequencyOfRunStatsChangeEvent">Frequency of run stats event.</param>
/// <param name="runStatsChangeEventTimeout">Timeout that triggers sending results regardless of cache size.</param>
Expand All @@ -26,17 +32,18 @@ public class TestExecutionContext
/// <param name="isDataCollectionEnabled">Whether data collection is enabled or not.</param>
/// <param name="areTestCaseLevelEventsRequired">Indicates whether test case level events are required.</param>
/// <param name="hasTestRun">True if ExecutionContext is associated with Test run, false otherwise.</param>
/// <param name="isDebug">True if ExecutionContext needs debugger, false otherwise.</param>
/// <param name="testCaseFilter">Filter criteria string for filtering tests.</param>
public TestExecutionContext(
long frequencyOfRunStatsChangeEvent,
TimeSpan runStatsChangeEventTimeout,
bool inIsolation,
bool keepAlive,
bool isDataCollectionEnabled,
bool areTestCaseLevelEventsRequired,
bool hasTestRun,
bool isDebug,
string testCaseFilter)
TimeSpan runStatsChangeEventTimeout,
bool inIsolation,
bool keepAlive,
bool isDataCollectionEnabled,
bool areTestCaseLevelEventsRequired,
bool hasTestRun,
bool isDebug,
string testCaseFilter)
{
this.FrequencyOfRunStatsChangeEvent = frequencyOfRunStatsChangeEvent;
this.RunStatsChangeEventTimeout = runStatsChangeEventTimeout;
Expand All @@ -51,142 +58,112 @@ public class TestExecutionContext
this.TestCaseFilter = testCaseFilter;
}

/// <summary>
/// The constructor.
/// </summary>
/// <param name="frequencyOfRunStatsChangeEvent">Frequency of run stats event.</param>
/// <param name="runStatsChangeEventTimeout">Timeout that triggers sending results regardless of cache size.</param>
/// <param name="inIsolation">Whether execution is out of process</param>
/// <param name="keepAlive">Whether executor process should be kept running after test run completion</param>
/// <param name="areTestCaseLevelEventsRequired">Indicates whether test case level events are required.</param>
/// <param name="isDebug"> Indicates whether the tests are being debugged. </param>
/// <param name="testCaseFilter">Filter criteria string for filtering tests.</param>
/// <remarks>This constructor is needed to re-create an instance on deserialization on the test host side.</remarks>
[JsonConstructor]
public TestExecutionContext(
long frequencyOfRunStatsChangeEvent,
TimeSpan runStatsChangeEventTimeout,
bool inIsolation,
bool keepAlive,
bool areTestCaseLevelEventsRequired,
bool isDebug,
string testCaseFilter)
{
this.FrequencyOfRunStatsChangeEvent = frequencyOfRunStatsChangeEvent;
this.RunStatsChangeEventTimeout = runStatsChangeEventTimeout;
this.InIsolation = inIsolation;
this.KeepAlive = keepAlive;
this.AreTestCaseLevelEventsRequired = areTestCaseLevelEventsRequired;

this.IsDebug = isDebug;

this.TestCaseFilter = testCaseFilter;
}

#endregion

#region Properties

/// <summary>
/// Gets frequency of run stats event.
/// Gets or sets the frequency of run stats event.
/// </summary>
[DataMember]
public long FrequencyOfRunStatsChangeEvent
{
get;
private set;
set;
}

/// <summary>
/// Gets the timeout that triggers sending results regardless of cache size.
/// Gets or sets the timeout that triggers sending results regardless of cache size.
/// </summary>
[DataMember]
public TimeSpan RunStatsChangeEventTimeout
{
get;
private set;
set;
}

/// <summary>
/// Gets a value indicating whether execution is out of process.
/// Gets or sets a value indicating whether execution is out of process.
/// </summary>
[DataMember]
public bool InIsolation
{
get;
private set;
set;
}

/// <summary>
/// Gets a value indicating whether executor process should be kept running after test run completion.
/// Gets or sets a value indicating whether executor process should be kept running after test run completion.
/// </summary>
[DataMember]
public bool KeepAlive
{
get;
private set;
set;
}

/// <summary>
/// Gets a value indicating whether test case level events need to be sent or not
/// Gets or sets a value indicating whether test case level events need to be sent or not
/// </summary>
[DataMember]
public bool AreTestCaseLevelEventsRequired
{
get;
private set;
set;
}

/// <summary>
/// Gets a value indicating whether execution is in debug mode.
/// Gets or sets a value indicating whether execution is in debug mode.
/// </summary>
[DataMember]
public bool IsDebug
{
get;
private set;
set;
}

/// <summary>
/// Gets the filter criteria for run with sources to filter test cases.
/// Gets or sets the filter criteria for run with sources to filter test cases.
/// </summary>
[DataMember]
public string TestCaseFilter
{
get;
private set;
set;
}

/// <summary>
/// Gets or sets a value indicating whether data collection is enabled or not.
/// </summary>
/// <remarks>This does not need to be serialized over to the test host process.</remarks>
[IgnoreDataMember]
public bool IsDataCollectionEnabled
{
get;
set;
}

/// <summary>
/// Gets a value indicating whether execution context is associated with a test run.
/// Gets or sets a value indicating whether execution context is associated with a test run.
/// </summary>
[IgnoreDataMember]
public bool HasTestRun
{
get;
private set;
set;
}

/// <summary>
/// Gets or sets a configuration associated with this run.
/// </summary>
/// <remarks>It is not serialized over wcf as the information is available in the runsettings</remarks>
/// <remarks>It is not serialized over <c>wcf </c> as the information is available in the run settings</remarks>
[IgnoreDataMember]
public RunConfiguration TestRunConfiguration
{
get;
set;
}


#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ public interface IDataSerializer
/// </summary>
/// <param name="messageType">Message Type</param>
/// <returns>Raw Serialized message</returns>
string SerializeObject(string messageType);
string SerializeMessage(string messageType);

/// <summary>
/// Serializes and creates a raw message given a message type and the object payload
/// </summary>
/// <param name="messageType">Message Type</param>
/// <param name="payload">Payload of the message</param>
/// <returns>Raw Serialized message</returns>
string SerializeObject(string messageType, object payload);
string SerializePayload(string messageType, object payload);
}
}

0 comments on commit 9907beb

Please sign in to comment.