diff --git a/Nuget.config b/Nuget.config
index 95c441ba5b..030d2c9659 100644
--- a/Nuget.config
+++ b/Nuget.config
@@ -7,6 +7,7 @@
+
diff --git a/scripts/Build.ps1 b/scripts/Build.ps1
index 1656d970fc..66637253d7 100644
--- a/scripts/Build.ps1
+++ b/scripts/Build.ps1
@@ -22,6 +22,12 @@ Param(
[Alias("vs")]
[System.String] $VersionSuffix = "dev",
+ [Parameter(Mandatory=$false)]
+ [System.String] $BuildVersionPrefix = "14.0",
+
+ [Parameter(Mandatory=$false)]
+ [System.String] $BuildVersionSuffix = "9999.99",
+
[Parameter(Mandatory=$false)]
[System.String] $Target = "Build",
@@ -74,6 +80,7 @@ $TFB_Configuration = $Configuration
$TFB_FrameworkVersion = $FrameworkVersion
$TFB_AdapterVersion = $AdapterVersion
$TFB_VersionSuffix = $VersionSuffix
+$TFB_BuildVersion = $BuildVersionPrefix + "." + $BuildVersionSuffix
$TFB_SkipRestore = $SkipRestore
$TFB_Clean = $Clean
$TFB_ClearPackageCache = $ClearPackageCache
@@ -249,8 +256,8 @@ function Invoke-Build([string] $solution, $hasVsixExtension = "false")
$solutionFailureLog = Join-Path -path $solutionDir -childPath "msbuild.err"
Write-Log " Building $solution..."
- Write-Verbose "$msbuild /t:$Target /p:Configuration=$configuration /tv:$msbuildVersion /v:m /flp1:Summary`;Verbosity=diagnostic`;Encoding=UTF-8`;LogFile=$solutionSummaryLog /flp2:WarningsOnly`;Verbosity=diagnostic`;Encoding=UTF-8`;LogFile=$solutionWarningLog /flp3:ErrorsOnly`;Verbosity=diagnostic`;Encoding=UTF-8`;LogFile=$solutionFailureLog /p:IsLocalizedBuild=$TFB_IsLocalizedBuild /p:UpdateXlf=$TFB_UpdateXlf $solutionPath"
- & $msbuild /t:$Target /p:Configuration=$configuration /tv:$msbuildVersion /v:m /flp1:Summary`;Verbosity=diagnostic`;Encoding=UTF-8`;LogFile=$solutionSummaryLog /flp2:WarningsOnly`;Verbosity=diagnostic`;Encoding=UTF-8`;LogFile=$solutionWarningLog /flp3:ErrorsOnly`;Verbosity=diagnostic`;Encoding=UTF-8`;LogFile=$solutionFailureLog /p:IsLocalizedBuild=$TFB_IsLocalizedBuild /p:UpdateXlf=$TFB_UpdateXlf $solutionPath
+ Write-Verbose "$msbuild /t:$Target /p:Configuration=$configuration /tv:$msbuildVersion /v:m /flp1:Summary`;Verbosity=diagnostic`;Encoding=UTF-8`;LogFile=$solutionSummaryLog /flp2:WarningsOnly`;Verbosity=diagnostic`;Encoding=UTF-8`;LogFile=$solutionWarningLog /flp3:ErrorsOnly`;Verbosity=diagnostic`;Encoding=UTF-8`;LogFile=$solutionFailureLog /p:IsLocalizedBuild=$TFB_IsLocalizedBuild /p:UpdateXlf=$TFB_UpdateXlf /p:BuildVersion=$TFB_BuildVersion $solutionPath"
+ & $msbuild /t:$Target /p:Configuration=$configuration /tv:$msbuildVersion /v:m /flp1:Summary`;Verbosity=diagnostic`;Encoding=UTF-8`;LogFile=$solutionSummaryLog /flp2:WarningsOnly`;Verbosity=diagnostic`;Encoding=UTF-8`;LogFile=$solutionWarningLog /flp3:ErrorsOnly`;Verbosity=diagnostic`;Encoding=UTF-8`;LogFile=$solutionFailureLog /p:IsLocalizedBuild=$TFB_IsLocalizedBuild /p:UpdateXlf=$TFB_UpdateXlf /p:BuildVersion=$TFB_BuildVersion $solutionPath
if ($lastExitCode -ne 0) {
throw "Build failed with an exit code of '$lastExitCode'."
diff --git a/scripts/PortableToFullPdb.ps1 b/scripts/PortableToFullPdb.ps1
new file mode 100644
index 0000000000..e62263a3b2
--- /dev/null
+++ b/scripts/PortableToFullPdb.ps1
@@ -0,0 +1,70 @@
+# Copyright (c) Microsoft. All rights reserved.
+# Portable to Full PDB conversion script for Test Platform.
+
+[CmdletBinding()]
+Param(
+ [Parameter(Mandatory=$false)]
+ [ValidateSet("Debug", "Release")]
+ [System.String] $Configuration = "Release"
+)
+
+#
+# Variables
+#
+Write-Verbose "Setup environment variables."
+$TF_ROOT_DIR = (Get-Item (Split-Path $MyInvocation.MyCommand.Path)).Parent.FullName
+$TF_PACKAGES_DIR = Join-Path $TF_ROOT_DIR "packages"
+$TF_OUT_DIR = Join-Path $TF_ROOT_DIR "artifacts"
+$TF_PortablePdbs =@("PlatformServices.NetCore\netstandard1.5\Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.pdb")
+
+$PdbConverterToolVersion = "1.1.0-beta1-62316-01"
+
+function Locate-PdbConverterTool
+{
+ $pdbConverter = Join-Path -path $TF_PACKAGES_DIR -ChildPath "Pdb2Pdb.$PdbConverterToolVersion\tools\Pdb2Pdb.exe"
+
+ if (!(Test-Path -path $pdbConverter))
+ {
+ throw "Unable to locate Pdb2Pdb converter exe in path '$pdbConverter'."
+ }
+
+ Write-Verbose "Pdb2Pdb converter path is : $pdbConverter"
+ return $pdbConverter
+
+}
+
+function ConvertPortablePdbToWindowsPdb
+{
+ foreach($TF_PortablePdb in $TF_PortablePdbs)
+ {
+ $portablePdbs += Join-Path -path $TF_OUT_DIR\$Configuration -childPath $TF_PortablePdb
+ }
+
+ $pdbConverter = Locate-PdbConverterTool
+
+ foreach($portablePdb in $portablePdbs)
+ {
+ # First check if corresponding dll exists
+ $dllOrExePath = $portablePdb -replace ".pdb",".dll"
+
+ if(!(Test-Path -path $dllOrExePath))
+ {
+ # If no corresponding dll found, check if exe exists
+ $dllOrExePath = $portablePdb -replace ".pdb",".exe"
+
+ if(!(Test-Path -path $dllOrExePath))
+ {
+ throw "Unable to locate dll/exe corresponding to $portablePdb"
+ }
+ }
+
+ $fullpdb = $portablePdb -replace ".pdb",".pdbfull"
+
+ Write-Verbose "$pdbConverter $dll /pdb $portablePdb /out $fullpdb"
+ & $pdbConverter $dllOrExePath /pdb $portablePdb /out $fullpdb
+ }
+}
+
+Write-Verbose "Converting Portable pdbs to Windows(Full) Pdbs..."
+ConvertPortablePdbToWindowsPdb
+
diff --git a/scripts/SetBuildNumber.ps1 b/scripts/SetBuildNumber.ps1
index 8b6a0bbd5f..97252bef6f 100644
--- a/scripts/SetBuildNumber.ps1
+++ b/scripts/SetBuildNumber.ps1
@@ -30,7 +30,7 @@ function Set_BuildNumber()
Write-Verbose("Build number used: " + $buildNumber)
# This sets the build number.
- Write-Host("##vso[build.updatebuildnumber]$buildNumber")
+ Write-Host("##vso[task.setvariable variable=BuildVersionSuffix]$buildNumber")
}
Set_BuildNumber
diff --git a/scripts/build/TestFx.targets b/scripts/build/TestFx.targets
index edef22344a..20340bb945 100644
--- a/scripts/build/TestFx.targets
+++ b/scripts/build/TestFx.targets
@@ -86,7 +86,7 @@
0.1
14.0
$(MajorVersion).0.0
- $(MajorVersion).$(TFBuildNumber)
+ $(MajorVersion).$(TFBuildNumber)
diff --git a/scripts/toolset/packages.config b/scripts/toolset/packages.config
index e7aa7c09f6..fb85da1e92 100644
--- a/scripts/toolset/packages.config
+++ b/scripts/toolset/packages.config
@@ -5,4 +5,5 @@
+
\ No newline at end of file
diff --git a/src/Adapter/MSTest.CoreAdapter/Discovery/AssemblyEnumeratorWrapper.cs b/src/Adapter/MSTest.CoreAdapter/Discovery/AssemblyEnumeratorWrapper.cs
index a48c202cbf..ca2912a5e6 100644
--- a/src/Adapter/MSTest.CoreAdapter/Discovery/AssemblyEnumeratorWrapper.cs
+++ b/src/Adapter/MSTest.CoreAdapter/Discovery/AssemblyEnumeratorWrapper.cs
@@ -76,41 +76,12 @@ internal ICollection GetTests(
fullFilePath,
ex);
- // Loading a WinPRT dll on the phone produces a
- // FileNotFoundException. We check if we get FileNotFoundException
- // in spite of the dll existing and try and load the dll from the full path in this case.
- try
- {
- if (PlatformServiceProvider.Instance.FileOperations.DoesFileExist(assemblyFileName))
- {
- var assembly = Assembly.Load(new AssemblyName(assemblyFileName));
- }
- }
- catch (Exception e)
- {
- warnings.Add(e.Message);
- return null;
- }
-
- warnings.Add(ex.Message);
- return null;
- }
- catch (ReflectionTypeLoadException ex)
- {
- warnings.Add(ex.Message);
- PlatformServiceProvider.Instance.AdapterTraceLogger.LogWarning(
- "MSPhoneTestDiscoverer.TryGetTests: Failed to discover tests from {0}. Reason:{1}",
- assemblyFileName,
- ex);
- PlatformServiceProvider.Instance.AdapterTraceLogger.LogWarning("Exceptions thrown from the Loader :");
-
- if (ex.LoaderExceptions != null)
- {
- foreach (var loaderEx in ex.LoaderExceptions)
- {
- PlatformServiceProvider.Instance.AdapterTraceLogger.LogWarning("{0}", loaderEx);
- }
- }
+ var message = string.Format(
+ CultureInfo.CurrentCulture,
+ "Failed to discover tests from assembly {0}. Reason:{1}",
+ fullFilePath,
+ ex.Message);
+ warnings.Add(message);
return null;
}
diff --git a/src/Adapter/MSTest.CoreAdapter/Execution/TestClassInfo.cs b/src/Adapter/MSTest.CoreAdapter/Execution/TestClassInfo.cs
index 32424086b6..ccd970a5aa 100644
--- a/src/Adapter/MSTest.CoreAdapter/Execution/TestClassInfo.cs
+++ b/src/Adapter/MSTest.CoreAdapter/Execution/TestClassInfo.cs
@@ -101,7 +101,7 @@ internal set
}
///
- /// Gets a value indicating whether is class initialize executed.
+ /// Gets a value indicating whether class initialize has executed.
///
public bool IsClassInitializeExecuted { get; internal set; }
@@ -295,37 +295,40 @@ public string RunClassCleanup()
return null;
}
- try
+ if (this.IsClassInitializeExecuted || this.ClassInitializeMethod == null)
{
- this.ClassCleanupMethod.InvokeAsSynchronousTask(null);
-
- return null;
- }
- catch (Exception exception)
- {
- var realException = exception.InnerException ?? exception;
-
- string errorMessage;
-
- // special case AssertFailedException to trim off part of the stack trace
- if (realException is AssertFailedException ||
- realException is AssertInconclusiveException)
+ try
{
- errorMessage = realException.Message;
+ this.ClassCleanupMethod.InvokeAsSynchronousTask(null);
}
- else
+ catch (Exception exception)
{
- errorMessage = StackTraceHelper.GetExceptionMessage(realException);
+ var realException = exception.InnerException ?? exception;
+
+ string errorMessage;
+
+ // special case AssertFailedException to trim off part of the stack trace
+ if (realException is AssertFailedException ||
+ realException is AssertInconclusiveException)
+ {
+ errorMessage = realException.Message;
+ }
+ else
+ {
+ errorMessage = StackTraceHelper.GetExceptionMessage(realException);
+ }
+
+ return string.Format(
+ CultureInfo.CurrentCulture,
+ Resource.UTA_ClassCleanupMethodWasUnsuccesful,
+ this.ClassType.Name,
+ this.ClassCleanupMethod.Name,
+ errorMessage,
+ StackTraceHelper.GetStackTraceInformation(realException)?.ErrorStackTrace);
}
-
- return string.Format(
- CultureInfo.CurrentCulture,
- Resource.UTA_ClassCleanupMethodWasUnsuccesful,
- this.ClassType.Name,
- this.ClassCleanupMethod.Name,
- errorMessage,
- StackTraceHelper.GetStackTraceInformation(realException)?.ErrorStackTrace);
}
+
+ return null;
}
}
}
\ No newline at end of file
diff --git a/src/Adapter/MSTest.CoreAdapter/Execution/TestExecutionManager.cs b/src/Adapter/MSTest.CoreAdapter/Execution/TestExecutionManager.cs
index 74db14ba75..e3e08bd895 100644
--- a/src/Adapter/MSTest.CoreAdapter/Execution/TestExecutionManager.cs
+++ b/src/Adapter/MSTest.CoreAdapter/Execution/TestExecutionManager.cs
@@ -322,6 +322,9 @@ private void CacheSessionParameters(IRunContext runContext, ITestExecutionRecord
var testRunParameters = RunSettingsUtilities.GetTestRunParameters(runContext.RunSettings.SettingsXml);
if (testRunParameters != null)
{
+ // Clear sessionParameters to prevent key collisions of test run parameters in case
+ // "Keep Test Execution Engine Alive" is selected in VS.
+ this.sessionParameters.Clear();
foreach (var kvp in testRunParameters)
{
this.sessionParameters.Add(kvp);
diff --git a/src/Adapter/MSTest.CoreAdapter/TestMethodFilter.cs b/src/Adapter/MSTest.CoreAdapter/TestMethodFilter.cs
index 118f645648..154be33e22 100644
--- a/src/Adapter/MSTest.CoreAdapter/TestMethodFilter.cs
+++ b/src/Adapter/MSTest.CoreAdapter/TestMethodFilter.cs
@@ -46,7 +46,7 @@ internal ITestCaseFilterExpression GetFilterExpression(IDiscoveryContext context
{
try
{
- filter = (context is IRunContext) ? this.GetTestCaseFilterFromRunContext(context as IRunContext) : this.GetTestCaseFilterFromDiscoveryContext(context);
+ filter = (context is IRunContext) ? this.GetTestCaseFilterFromRunContext(context as IRunContext) : this.GetTestCaseFilterFromDiscoveryContext(context, logger);
}
catch (TestPlatformFormatException ex)
{
@@ -111,7 +111,7 @@ private ITestCaseFilterExpression GetTestCaseFilterFromRunContext(IRunContext co
///
/// Discovery context
/// Filter expression.
- private ITestCaseFilterExpression GetTestCaseFilterFromDiscoveryContext(IDiscoveryContext context)
+ private ITestCaseFilterExpression GetTestCaseFilterFromDiscoveryContext(IDiscoveryContext context, IMessageLogger logger)
{
try
{
@@ -119,10 +119,19 @@ private ITestCaseFilterExpression GetTestCaseFilterFromDiscoveryContext(IDiscove
MethodInfo methodGetTestCaseFilter = context.GetType().GetRuntimeMethod("GetTestCaseFilter", new[] { typeof(IEnumerable), typeof(Func) });
return (ITestCaseFilterExpression)methodGetTestCaseFilter?.Invoke(context, new object[] { this.supportedProperties.Keys, (Func)this.PropertyProvider });
}
- catch (TargetInvocationException ex)
+ catch (Exception ex)
{
- throw ex.InnerException;
+ // In case of UWP .Net Native Tool Chain compilation. Invoking methods via Reflection doesn't work, hence discovery always fails.
+ // Hence throwing exception only if it is of type TargetInvocationException(i.e. Method got invoked but something went wrong in GetTestCaseFilter Method)
+ if (ex is TargetInvocationException)
+ {
+ throw ex.InnerException;
+ }
+
+ logger.SendMessage(TestMessageLevel.Warning, ex.Message);
}
+
+ return null;
}
}
}
\ No newline at end of file
diff --git a/src/Package/MSTest.Internal.TestFx.Documentation.nuspec b/src/Package/MSTest.Internal.TestFx.Documentation.nuspec
index e22fc56ac8..85e0b8fdce 100644
--- a/src/Package/MSTest.Internal.TestFx.Documentation.nuspec
+++ b/src/Package/MSTest.Internal.TestFx.Documentation.nuspec
@@ -12,7 +12,7 @@
https://github.com/microsoft/testfx
http://www.microsoft.com/web/webpi/eula/net_library_eula_enu.htm
http://go.microsoft.com/fwlink/?LinkID=288859
- Copyright © Microsoft Corporation
+ © Microsoft Corporation. All rights reserved.
MSTest TestFramework MSTestV2
diff --git a/src/Package/MSTest.TestAdapter.Dotnet.nuspec b/src/Package/MSTest.TestAdapter.Dotnet.nuspec
index f9ff1d76b3..aa9b030271 100644
--- a/src/Package/MSTest.TestAdapter.Dotnet.nuspec
+++ b/src/Package/MSTest.TestAdapter.Dotnet.nuspec
@@ -11,7 +11,7 @@
https://github.com/microsoft/testfx
http://www.microsoft.com/web/webpi/eula/net_library_eula_enu.htm
http://go.microsoft.com/fwlink/?LinkID=288859
- Copyright © Microsoft Corporation
+ © Microsoft Corporation. All rights reserved.
diff --git a/src/Package/MSTest.TestAdapter.Enu.nuspec b/src/Package/MSTest.TestAdapter.Enu.nuspec
index d96d6b8c49..25d97bc984 100644
--- a/src/Package/MSTest.TestAdapter.Enu.nuspec
+++ b/src/Package/MSTest.TestAdapter.Enu.nuspec
@@ -18,7 +18,7 @@
https://github.com/microsoft/testfx
http://www.microsoft.com/web/webpi/eula/net_library_eula_enu.htm
http://go.microsoft.com/fwlink/?LinkID=288859
- Copyright © Microsoft Corporation
+ © Microsoft Corporation. All rights reserved.
MSTest TestFramework TestAdapter VisualStudio Unittest MSTestV2 Microsoft
diff --git a/src/Package/MSTest.TestAdapter.nuspec b/src/Package/MSTest.TestAdapter.nuspec
index 09457971e0..8ef68ec7f8 100644
--- a/src/Package/MSTest.TestAdapter.nuspec
+++ b/src/Package/MSTest.TestAdapter.nuspec
@@ -18,7 +18,7 @@
https://github.com/microsoft/testfx
http://www.microsoft.com/web/webpi/eula/net_library_eula_enu.htm
http://go.microsoft.com/fwlink/?LinkID=288859
- Copyright © Microsoft Corporation
+ © Microsoft Corporation. All rights reserved.
MSTest TestFramework TestAdapter VisualStudio Unittest MSTestV2 Microsoft
diff --git a/src/Package/MSTest.TestAdapter.symbols.nuspec b/src/Package/MSTest.TestAdapter.symbols.nuspec
index 1a4385ddf4..0c1a53d8dc 100644
--- a/src/Package/MSTest.TestAdapter.symbols.nuspec
+++ b/src/Package/MSTest.TestAdapter.symbols.nuspec
@@ -18,7 +18,7 @@
https://github.com/microsoft/testfx
http://www.microsoft.com/web/webpi/eula/net_library_eula_enu.htm
http://go.microsoft.com/fwlink/?LinkID=288859
- Copyright © Microsoft Corporation
+ © Microsoft Corporation. All rights reserved.
MSTest TestFramework TestAdapter VisualStudio Unittest MSTestV2 Microsoft
diff --git a/src/Package/MSTest.TestFramework.enu.nuspec b/src/Package/MSTest.TestFramework.enu.nuspec
index 29f8fc1251..b7daa2b9d5 100644
--- a/src/Package/MSTest.TestFramework.enu.nuspec
+++ b/src/Package/MSTest.TestFramework.enu.nuspec
@@ -23,7 +23,7 @@
https://github.com/microsoft/testfx
http://www.microsoft.com/web/webpi/eula/net_library_eula_enu.htm
http://go.microsoft.com/fwlink/?LinkID=288859
- Copyright © Microsoft Corporation
+ © Microsoft Corporation. All rights reserved.
MSTest TestFramework Unittest MSTestV2 Microsoft Test Testing TDD Framework
diff --git a/src/Package/MSTest.TestFramework.nuspec b/src/Package/MSTest.TestFramework.nuspec
index 141d8dcd9e..2b0ce7c54c 100644
--- a/src/Package/MSTest.TestFramework.nuspec
+++ b/src/Package/MSTest.TestFramework.nuspec
@@ -23,7 +23,7 @@
https://github.com/microsoft/testfx
http://www.microsoft.com/web/webpi/eula/net_library_eula_enu.htm
http://go.microsoft.com/fwlink/?LinkID=288859
- Copyright © Microsoft Corporation
+ © Microsoft Corporation. All rights reserved.
MSTest TestFramework Unittest MSTestV2 Microsoft Test Testing TDD Framework
diff --git a/src/Package/MSTest.TestFramework.symbols.nuspec b/src/Package/MSTest.TestFramework.symbols.nuspec
index 66d2ef2139..81a92a79ee 100644
--- a/src/Package/MSTest.TestFramework.symbols.nuspec
+++ b/src/Package/MSTest.TestFramework.symbols.nuspec
@@ -22,7 +22,7 @@
https://github.com/microsoft/testfx
http://www.microsoft.com/web/webpi/eula/net_library_eula_enu.htm
http://go.microsoft.com/fwlink/?LinkID=288859
- Copyright © Microsoft Corporation
+ © Microsoft Corporation. All rights reserved.
MSTest TestFramework Unittest MSTestV2 Microsoft Test Testing TDD Framework
diff --git a/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Execution/TestClassInfoTests.cs b/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Execution/TestClassInfoTests.cs
index bb4e78c111..e3f8285b88 100644
--- a/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Execution/TestClassInfoTests.cs
+++ b/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Execution/TestClassInfoTests.cs
@@ -111,6 +111,37 @@ public void TestClassInfoClassCleanupMethodSetShouldThrowForMultipleClassCleanup
ActionUtility.ActionShouldThrowExceptionOfType(action, typeof(TypeInspectionException));
}
+ [TestMethod]
+ public void TestClassInfoClassCleanupMethodShouldNotInvokeWhenNoTestClassInitializedIsCalled()
+ {
+ var classcleanupCallCount = 0;
+ DummyTestClass.ClassCleanupMethodBody = () => classcleanupCallCount++;
+
+ this.testClassInfo.ClassCleanupMethod = typeof(DummyTestClass).GetMethod("ClassCleanupMethod");
+ this.testClassInfo.ClassInitializeMethod = typeof(DummyTestClass).GetMethod("ClassInitializeMethod");
+
+ var ret = this.testClassInfo.RunClassCleanup(); // call cleanup without calling init
+
+ Assert.AreEqual(null, ret);
+ Assert.AreEqual(0, classcleanupCallCount);
+ }
+
+ [TestMethod]
+ public void TestClassInfoClassCleanupMethodShouldInvokeWhenTestClassInitializedIsCalled()
+ {
+ var classcleanupCallCount = 0;
+ DummyTestClass.ClassCleanupMethodBody = () => classcleanupCallCount++;
+
+ this.testClassInfo.ClassCleanupMethod = typeof(DummyTestClass).GetMethod("ClassCleanupMethod");
+ this.testClassInfo.ClassInitializeMethod = typeof(DummyTestClass).GetMethod("ClassInitializeMethod");
+
+ this.testClassInfo.RunClassInitialize(this.testContext);
+ var ret = this.testClassInfo.RunClassCleanup(); // call cleanup without calling init
+
+ Assert.AreEqual(null, ret);
+ Assert.AreEqual(1, classcleanupCallCount);
+ }
+
[TestMethod]
public void TestClassInfoHasExecutableCleanupMethodShouldReturnFalseIfClassDoesNotHaveCleanupMethod()
{
@@ -275,6 +306,16 @@ public void RunClassInitializeShouldThrowForAlreadyExecutedTestClassInitWithExce
exception.Message);
}
+ [TestMethod]
+ public void RunClassCleanupShouldInvokeIfClassCleanupMethod()
+ {
+ var classcleanupCallCount = 0;
+ DummyTestClass.ClassCleanupMethodBody = () => classcleanupCallCount++;
+ this.testClassInfo.ClassCleanupMethod = typeof(DummyTestClass).GetMethod("ClassCleanupMethod");
+ Assert.IsNull(this.testClassInfo.RunClassCleanup());
+ Assert.AreEqual(1, classcleanupCallCount);
+ }
+
[TestMethod]
public void RunAssemblyInitializeShouldPassOnTheTestContextToAssemblyInitMethod()
{
@@ -300,24 +341,13 @@ public void RunClassCleanupShouldNotInvokeIfClassCleanupIsNull()
Assert.AreEqual(0, classcleanupCallCount);
}
- [TestMethod]
- public void RunClassCleanupShouldInvokeIfClassCleanupMethod()
- {
- var classcleanupCallCount = 0;
- DummyTestClass.ClassCleanupMethodBody = () => classcleanupCallCount++;
-
- this.testClassInfo.ClassCleanupMethod = typeof(DummyTestClass).GetMethod("ClassCleanupMethod");
-
- Assert.IsNull(this.testClassInfo.RunClassCleanup());
- Assert.AreEqual(1, classcleanupCallCount);
- }
-
[TestMethod]
public void RunClassCleanupShouldReturnAssertFailureExceptionDetails()
{
DummyTestClass.ClassCleanupMethodBody = () => UTF.Assert.Fail("Test Failure.");
this.testClassInfo.ClassCleanupMethod = typeof(DummyTestClass).GetMethod("ClassCleanupMethod");
+
StringAssert.StartsWith(
this.testClassInfo.RunClassCleanup(),
"Class Cleanup method DummyTestClass.ClassCleanupMethod failed. Error Message: Assert.Fail failed. Test Failure.. Stack Trace: at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests.Execution.TestClassInfoTests.<>c.");
diff --git a/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Execution/TestExecutionManagerTests.cs b/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Execution/TestExecutionManagerTests.cs
index 9900073589..328d82b04d 100644
--- a/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Execution/TestExecutionManagerTests.cs
+++ b/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Execution/TestExecutionManagerTests.cs
@@ -145,14 +145,12 @@ public void RunTestsForMultipleTestShouldSendMultipleResults()
List expectedTestCaseStartList = new List() { "PassingTest", "FailingTest" };
List expectedTestCaseEndList = new List() { "PassingTest:Passed", "FailingTest:Failed" };
- List expectedResultList = new List() { "PassingTest Passed", "FailingTest Failed\r\n Message: (null)" };
+ List expectedResultList = new List() { "PassingTest Passed", "FailingTest Failed\r\n Message: Assert.Fail failed." };
CollectionAssert.AreEqual(expectedTestCaseStartList, this.frameworkHandle.TestCaseStartList);
CollectionAssert.AreEqual(expectedTestCaseEndList, this.frameworkHandle.TestCaseEndList);
- Assert.AreEqual("PassingTest Passed", this.frameworkHandle.ResultsList[0]);
- StringAssert.Contains(
- this.frameworkHandle.ResultsList[1],
- "FailingTest Failed\r\n Message: Assert.Fail failed. \r\n StackTrace:\r\n at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests.Execution.TestExecutionManagerTests.DummyTestClass.FailingTest()");
+ Assert.AreEqual(expectedResultList[0], this.frameworkHandle.ResultsList[0]);
+ StringAssert.Contains(this.frameworkHandle.ResultsList[1], expectedResultList[1]);
}
[TestMethodV1]
@@ -293,6 +291,38 @@ public void RunTestsForTestShouldPassInDeploymentInformationAsPropertiesToTheTes
testablePlatformService.MockSettingsProvider.Verify(sp => sp.GetProperties(It.IsAny()), Times.Once);
}
+ [TestMethodV1]
+ public void RunTestsShouldClearSessionParametersAcrossRuns()
+ {
+ var testCase = this.GetTestCase(typeof(DummyTestClass), "PassingTest");
+
+ TestCase[] tests = new[] { testCase };
+ this.runContext.MockRunSettings.Setup(rs => rs.SettingsXml).Returns(
+ @"
+
+
+
+
+ ");
+
+ // Trigger First Run
+ this.TestExecutionManager.RunTests(tests, this.runContext, this.frameworkHandle, new TestRunCancellationToken());
+
+ // Update runsettings to have different values for similar keys
+ this.runContext.MockRunSettings.Setup(rs => rs.SettingsXml).Returns(
+ @"
+
+
+
+
+ ");
+
+ // Trigger another Run
+ this.TestExecutionManager.RunTests(tests, this.runContext, this.frameworkHandle, new TestRunCancellationToken());
+
+ Assert.AreEqual(DummyTestClass.TestContextProperties["webAppUrl"], "http://updatedLocalHost");
+ }
+
#endregion
#region Run Tests on Sources
diff --git a/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Execution/UnitTestRunnerTests.cs b/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Execution/UnitTestRunnerTests.cs
index 9644cd927a..0c47758f87 100644
--- a/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Execution/UnitTestRunnerTests.cs
+++ b/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Execution/UnitTestRunnerTests.cs
@@ -14,7 +14,6 @@ namespace Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests.Execution
using System.Reflection;
using System.Text;
using System.Xml;
-
using global::MSTestAdapter.TestUtilities;
using Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter;
using Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution;