Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading;
using Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Interface;
using Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Interface.ObjectModel;
Expand All @@ -31,7 +32,7 @@ public class TestContextImplementation : UTF.TestContext, ITestContext
/// <summary>
/// List of result files associated with the test
/// </summary>
private IList<string> testResultFiles;
private readonly IList<string> testResultFiles;

/// <summary>
/// Properties
Expand Down Expand Up @@ -213,6 +214,22 @@ public UTF.TestContext Context
}
}

/// <summary>
/// Adds a file name to the list in TestResult.ResultFileNames
/// </summary>
/// <param name="fileName">
/// The file Name.
/// </param>
public override void AddResultFile(string fileName)
{
if (string.IsNullOrEmpty(fileName))
{
throw new ArgumentException("The parameter should not be null or empty.", "fileName");
}

this.testResultFiles.Add(Path.GetFullPath(fileName));
}

/// <summary>
/// Set the unit-test outcome
/// </summary>
Expand Down Expand Up @@ -255,12 +272,21 @@ public void AddProperty(string propertyName, string propertyValue)
}

/// <summary>
/// Returning null as this feature is not supported in ASP .net and UWP
/// Result files attached
/// </summary>
/// <returns>List of result files. Null presently.</returns>
/// <returns>List of result files generated in run.</returns>
public IList<string> GetResultFiles()
{
return null;
if (this.testResultFiles.Count == 0)
{
return null;
}

IList<string> results = this.testResultFiles.ToList();

this.testResultFiles.Clear();

return results;
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading;
using Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Interface;
using Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Interface.ObjectModel;
Expand All @@ -29,6 +30,11 @@ public class TestContextImplementation : UTF.TestContext, ITestContext
private static readonly string FullyQualifiedTestClassNameLabel = "FullyQualifiedTestClassName";
private static readonly string TestNameLabel = "TestName";

/// <summary>
/// List of result files associated with the test
/// </summary>
private readonly IList<string> testResultFiles;

/// <summary>
/// Properties
/// </summary>
Expand Down Expand Up @@ -61,6 +67,7 @@ public TestContextImplementation(ITestMethod testMethod, StringWriter writer, ID
this.testMethod = testMethod;
this.properties = new Dictionary<string, object>(properties);
this.stringWriter = writer;
this.testResultFiles = new List<string>();
this.CancellationTokenSource = new CancellationTokenSource();
this.InitializeProperties();
}
Expand Down Expand Up @@ -133,6 +140,19 @@ public UTF.TestContext Context
}
}

/// <summary>
/// Adds a file name to the list in TestResult.ResultFileNames
/// </summary>
/// <param name="fileName">
/// The file Name.
/// </param>
public override void AddResultFile(string fileName)
{
// No-op function
// will be replaced at runtime time by PlatformServices Desktop/NetCore
// depending the target framework
}

/// <summary>
/// Set the unit-test outcome
/// </summary>
Expand Down Expand Up @@ -174,15 +194,6 @@ public void AddProperty(string propertyName, string propertyValue)
this.properties.Add(propertyName, propertyValue);
}

/// <summary>
/// Returning null as this feature is not supported in ASP .net and UWP
/// </summary>
/// <returns>List of result files. Null presently.</returns>
public IList<string> GetResultFiles()
{
return null;
}

/// <summary>
/// When overridden in a derived class, used to write trace messages while the
/// test is running.
Expand Down Expand Up @@ -230,6 +241,15 @@ public override void WriteLine(string format, params object[] args)
}
}

/// <summary>
/// Returns null as this feature is not supported in ASP .net and UWP
/// </summary>
/// <returns>List of result files. Null presently.</returns>
public IList<string> GetResultFiles()
{
return null;
}

/// <summary>
/// Gets messages from the testContext writeLines
/// </summary>
Expand Down
8 changes: 8 additions & 0 deletions src/TestFramework/Extension.Core/NetCoreTestContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ public abstract class TestContext
/// </summary>
public virtual UnitTestOutcome CurrentTestOutcome => UnitTestOutcome.Unknown;

/// <summary>
/// Adds a file name to the list in TestResult.ResultFileNames
/// </summary>
/// <param name="fileName">
/// The file Name.
/// </param>
public abstract void AddResultFile(string fileName);

/// <summary>
/// Used to write trace messages while the test is running
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<Compile Include="..\PlatformServices.Shared.Unit.Tests\netstandard1.0\ns10FileOperationsTests.cs" Link="Services\ns10FileOperationsTests.cs" />
<Compile Include="..\PlatformServices.Shared.Unit.Tests\netstandard1.0\ns10DiaSessionOperationsTests.cs" Link="Services\ns10DiaSessionOperationsTests.cs" />
<Compile Include="..\PlatformServices.Shared.Unit.Tests\netstandard1.0\ns10ReflectionOperationsTests.cs" Link="Services\ns10ReflectionOperationsTests.cs" />
<Compile Include="..\PlatformServices.Shared.Unit.Tests\netstandard1.0\ns10TestContextImplementationTests.cs" Link="Services\ns10TestContextImplementationTests.cs" />
<Compile Include="..\PlatformServices.Shared.Unit.Tests\netcore\NetCoreTestContextImplementationTests.cs" Link="Services\NetCoreTestContextImplementationTests.cs" />
<Compile Include="..\PlatformServices.Shared.Unit.Tests\netstandard1.0\ns10TestSourceHostTests.cs" Link="Services\ns10TestSourceHostTests.cs" />
<Compile Include="..\PlatformServices.Shared.Unit.Tests\netstandard1.0\ns10TestSourceTests.cs" Link="Services\ns10TestSourceTests.cs" />
<Compile Include="..\PlatformServices.Shared.Unit.Tests\netstandard1.0\ns10ThreadOperationsTests.cs" Link="Services\ns10ThreadOperationsTests.cs" />
Expand Down
Loading