Skip to content

Commit 0f33261

Browse files
committed
Test in release mode
1 parent 4517f8a commit 0f33261

File tree

5 files changed

+15
-64
lines changed

5 files changed

+15
-64
lines changed

test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/Execution/TestAssemblyInfoTests.cs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,8 @@ public void RunAssemblyInitializeShouldThrowTestFailedExceptionOnAssertionFailur
147147
Verify(
148148
exception.Message
149149
== "Assembly Initialization method Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests.Execution.TestAssemblyInfoTests+DummyTestClass.AssemblyInitializeMethod threw exception. Microsoft.VisualStudio.TestTools.UnitTesting.AssertFailedException: Assert.Fail failed. Test failure. Aborting test execution.");
150-
#if DEBUG
151150
Verify(exception.StackTraceInformation!.ErrorStackTrace.StartsWith(
152-
" at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests.Execution.TestAssemblyInfoTests.<>c.<RunAssemblyInitializeShouldThrowTestFailedExceptionOnAssertionFailure>", StringComparison.Ordinal));
153-
#endif
151+
" at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests.Execution.TestAssemblyInfoTests.<>c.<RunAssemblyInitializeShouldThrowTestFailedExceptionOnAssertionFailure>", StringComparison.Ordinal));
154152
Verify(exception.InnerException!.GetType() == typeof(AssertFailedException));
155153
}
156154

@@ -164,10 +162,8 @@ public void RunAssemblyInitializeShouldThrowTestFailedExceptionWithInconclusiveO
164162
Verify(
165163
exception.Message
166164
== "Assembly Initialization method Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests.Execution.TestAssemblyInfoTests+DummyTestClass.AssemblyInitializeMethod threw exception. Microsoft.VisualStudio.TestTools.UnitTesting.AssertInconclusiveException: Assert.Inconclusive failed. Test Inconclusive. Aborting test execution.");
167-
#if DEBUG
168165
Verify(exception.StackTraceInformation!.ErrorStackTrace.StartsWith(
169166
" at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests.Execution.TestAssemblyInfoTests.<>c.<RunAssemblyInitializeShouldThrowTestFailedExceptionWithInconclusiveOnAssertInconclusive>", StringComparison.Ordinal));
170-
#endif
171167
Verify(exception.InnerException!.GetType() == typeof(AssertInconclusiveException));
172168
}
173169

@@ -182,10 +178,8 @@ public void RunAssemblyInitializeShouldThrowTestFailedExceptionWithNonAssertExce
182178
Verify(
183179
exception.Message
184180
== "Assembly Initialization method Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests.Execution.TestAssemblyInfoTests+DummyTestClass.AssemblyInitializeMethod threw exception. System.ArgumentException: Some actualErrorMessage message. Aborting test execution.");
185-
#if DEBUG
186181
Verify(exception.StackTraceInformation!.ErrorStackTrace.StartsWith(
187-
" at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests.Execution.TestAssemblyInfoTests.<>c.<RunAssemblyInitializeShouldThrowTestFailedExceptionWithNonAssertExceptions>", StringComparison.Ordinal));
188-
#endif
182+
" at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests.Execution.TestAssemblyInfoTests.<>c.<RunAssemblyInitializeShouldThrowTestFailedExceptionWithNonAssertExceptions>", StringComparison.Ordinal));
189183
Verify(exception.InnerException!.GetType() == typeof(ArgumentException));
190184
Verify(exception.InnerException.InnerException!.GetType() == typeof(InvalidOperationException));
191185
}
@@ -205,10 +199,8 @@ public void RunAssemblyInitializeShouldThrowTheInnerMostExceptionWhenThereAreMul
205199
Verify(
206200
exception.Message
207201
== "Assembly Initialization method Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests.Execution.TestAssemblyInfoTests+DummyTestClass.AssemblyInitializeMethod threw exception. System.InvalidOperationException: I fail.. Aborting test execution.");
208-
#if DEBUG
209202
Verify(exception.StackTraceInformation!.ErrorStackTrace.StartsWith(
210203
" at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests.Execution.TestAssemblyInfoTests.FailingStaticHelper..cctor()", StringComparison.Ordinal));
211-
#endif
212204
Verify(exception.InnerException!.GetType() == typeof(InvalidOperationException));
213205
}
214206

test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/Execution/TestClassInfoTests.cs

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -338,10 +338,8 @@ public void RunClassInitializeShouldThrowTestFailedExceptionOnBaseInitializeMeth
338338
Verify(
339339
exception.Message
340340
== "Class Initialization method Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests.Execution.TestClassInfoTests+DummyTestClass.InitBaseClassMethod threw exception. System.ArgumentException: Some exception message.");
341-
#if DEBUG
342341
Verify(exception.StackTraceInformation!.ErrorStackTrace.StartsWith(
343-
" at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests.Execution.TestClassInfoTests.<>c.<RunClassInitializeShouldThrowTestFailedExceptionOnBaseInitializeMethodWithNonAssertExceptions>", StringComparison.Ordinal));
344-
#endif
342+
" at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests.Execution.TestClassInfoTests.<>c.<RunClassInitializeShouldThrowTestFailedExceptionOnBaseInitializeMethodWithNonAssertExceptions>", StringComparison.Ordinal));
345343
Verify(exception.InnerException!.GetType() == typeof(ArgumentException));
346344
Verify(exception.InnerException.InnerException!.GetType() == typeof(InvalidOperationException));
347345
}
@@ -358,10 +356,8 @@ public void RunClassInitializeShouldThrowTestFailedExceptionOnAssertionFailure()
358356
Verify(
359357
exception.Message
360358
== "Class Initialization method Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests.Execution.TestClassInfoTests+DummyTestClass.ClassInitializeMethod threw exception. Microsoft.VisualStudio.TestTools.UnitTesting.AssertFailedException: Assert.Fail failed. Test failure.");
361-
#if DEBUG
362359
Verify(exception.StackTraceInformation!.ErrorStackTrace.StartsWith(
363-
" at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests.Execution.TestClassInfoTests.<>c.<RunClassInitializeShouldThrowTestFailedExceptionOnAssertionFailure>", StringComparison.Ordinal));
364-
#endif
360+
" at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests.Execution.TestClassInfoTests.<>c.<RunClassInitializeShouldThrowTestFailedExceptionOnAssertionFailure>", StringComparison.Ordinal));
365361
Verify(exception.InnerException!.GetType() == typeof(AssertFailedException));
366362
}
367363

@@ -377,10 +373,8 @@ public void RunClassInitializeShouldThrowTestFailedExceptionWithInconclusiveOnAs
377373
Verify(
378374
exception.Message
379375
== "Class Initialization method Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests.Execution.TestClassInfoTests+DummyTestClass.ClassInitializeMethod threw exception. Microsoft.VisualStudio.TestTools.UnitTesting.AssertInconclusiveException: Assert.Inconclusive failed. Test Inconclusive.");
380-
#if DEBUG
381376
Verify(exception.StackTraceInformation!.ErrorStackTrace.StartsWith(
382-
" at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests.Execution.TestClassInfoTests.<>c.<RunClassInitializeShouldThrowTestFailedExceptionWithInconclusiveOnAssertInconclusive>", StringComparison.Ordinal));
383-
#endif
377+
" at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests.Execution.TestClassInfoTests.<>c.<RunClassInitializeShouldThrowTestFailedExceptionWithInconclusiveOnAssertInconclusive>", StringComparison.Ordinal));
384378
Verify(exception.InnerException!.GetType() == typeof(AssertInconclusiveException));
385379
}
386380

@@ -396,10 +390,8 @@ public void RunClassInitializeShouldThrowTestFailedExceptionWithNonAssertExcepti
396390
Verify(
397391
exception.Message
398392
== "Class Initialization method Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests.Execution.TestClassInfoTests+DummyTestClass.ClassInitializeMethod threw exception. System.ArgumentException: Argument exception.");
399-
#if DEBUG
400393
Verify(exception.StackTraceInformation!.ErrorStackTrace.StartsWith(
401-
" at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests.Execution.TestClassInfoTests.<>c.<RunClassInitializeShouldThrowTestFailedExceptionWithNonAssertExceptions>", StringComparison.Ordinal));
402-
#endif
394+
" at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests.Execution.TestClassInfoTests.<>c.<RunClassInitializeShouldThrowTestFailedExceptionWithNonAssertExceptions>", StringComparison.Ordinal));
403395
}
404396

405397
public void RunClassInitializeShouldThrowForAlreadyExecutedTestClassInitWithException()
@@ -438,11 +430,8 @@ public void RunClassInitializeShouldThrowTheInnerMostExceptionWhenThereAreMultip
438430
Verify(
439431
exception.Message
440432
== "Class Initialization method Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests.Execution.TestClassInfoTests+DummyTestClass.ClassInitializeMethod threw exception. System.InvalidOperationException: I fail..");
441-
#if DEBUG
442-
Verify(
443-
exception.StackTraceInformation!.ErrorStackTrace.StartsWith(
433+
Verify(exception.StackTraceInformation!.ErrorStackTrace.StartsWith(
444434
" at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests.Execution.TestClassInfoTests.FailingStaticHelper..cctor()", StringComparison.Ordinal));
445-
#endif
446435
Verify(exception.InnerException!.GetType() == typeof(InvalidOperationException));
447436
}
448437

@@ -500,12 +489,9 @@ public void RunClassCleanupShouldReturnAssertFailureExceptionDetails()
500489
Verify(classCleanupException is not null);
501490
Verify(classCleanupException.Message.StartsWith("Class Cleanup method DummyTestClass.ClassCleanupMethod failed.", StringComparison.Ordinal));
502491
Verify(classCleanupException.Message.Contains("Error Message: Assert.Fail failed. Test Failure."));
503-
#if DEBUG
504-
Verify(
505-
classCleanupException.Message.Contains(
506-
$"{typeof(TestClassInfoTests).FullName}.<>c.<{nameof(this.RunClassCleanupShouldReturnAssertFailureExceptionDetails)}>"),
507-
$"Value: {classCleanupException.Message}");
508-
#endif
492+
Verify(classCleanupException.Message.Contains(
493+
$"{typeof(TestClassInfoTests).FullName}.<>c.<{nameof(this.RunClassCleanupShouldReturnAssertFailureExceptionDetails)}>"),
494+
$"Value: {classCleanupException.Message}");
509495
}
510496

511497
public void RunClassCleanupShouldReturnAssertInconclusiveExceptionDetails()
@@ -522,11 +508,9 @@ public void RunClassCleanupShouldReturnAssertInconclusiveExceptionDetails()
522508
Verify(classCleanupException is not null);
523509
Verify(classCleanupException.Message.StartsWith("Class Cleanup method DummyTestClass.ClassCleanupMethod failed.", StringComparison.Ordinal));
524510
Verify(classCleanupException.Message.Contains("Error Message: Assert.Inconclusive failed. Test Inconclusive."));
525-
#if DEBUG
526-
Verify(
527-
classCleanupException.Message.Contains($"{typeof(TestClassInfoTests).FullName}.<>c.<{nameof(this.RunClassCleanupShouldReturnAssertInconclusiveExceptionDetails)}>"),
511+
Verify(classCleanupException.Message.Contains(
512+
$"{typeof(TestClassInfoTests).FullName}.<>c.<{nameof(this.RunClassCleanupShouldReturnAssertInconclusiveExceptionDetails)}>"),
528513
$"Value: {classCleanupException.Message}");
529-
#endif
530514
}
531515

532516
public void RunClassCleanupShouldReturnExceptionDetailsOfNonAssertExceptions()

test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/Execution/TestMethodInfoTests.cs

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -576,10 +576,8 @@ public async Task TestMethodInfoInvokeWhenTestThrowsReturnsExpectedResult()
576576
Verify(exception.Outcome == UTF.UnitTestOutcome.Failed);
577577
Verify(exception.InnerException!.GetType() == typeof(ArgumentException));
578578
Verify(exception.InnerException.InnerException!.GetType() == typeof(InvalidOperationException));
579-
#if DEBUG
580579
Verify(exception.StackTraceInformation!.ErrorStackTrace.StartsWith(
581-
" at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests.Execution.TestMethodInfoTests.<>c.<TestMethodInfoInvokeWhenTestThrowsReturnsExpectedResult>b__", StringComparison.Ordinal));
582-
#endif
580+
" at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests.Execution.TestMethodInfoTests.<>c.<TestMethodInfoInvokeWhenTestThrowsReturnsExpectedResult>b__", StringComparison.Ordinal));
583581
}
584582

585583
public async Task TestInitialize_WhenTestReturnsTaskFromException_DisplayProperException()
@@ -646,10 +644,8 @@ public async Task TestMethodInfoInvokeWhenTestThrowsAssertFailReturnsExpectedRes
646644
Verify(errorMessage == exception.Message);
647645
Verify(exception.Outcome == UTF.UnitTestOutcome.Failed);
648646
Verify(exception.InnerException!.GetType() == typeof(AssertFailedException));
649-
#if DEBUG
650647
Verify(exception.StackTraceInformation!.ErrorStackTrace.StartsWith(
651-
" at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests.Execution.TestMethodInfoTests.<>c.<TestMethodInfoInvokeWhenTestThrowsAssertFailReturnsExpectedResult>b__", StringComparison.Ordinal));
652-
#endif
648+
" at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests.Execution.TestMethodInfoTests.<>c.<TestMethodInfoInvokeWhenTestThrowsAssertFailReturnsExpectedResult>b__", StringComparison.Ordinal));
653649
}
654650

655651
public async Task TestMethodInfoInvokeWhenTestThrowsAssertInconclusiveReturnsExpectedResult()
@@ -682,10 +678,8 @@ public async Task TestMethodInfoInvokeWhenTestThrowsAssertInconclusiveReturnsExp
682678
Verify(errorMessage == exception.Message);
683679
Verify(exception.Outcome == UTF.UnitTestOutcome.Inconclusive);
684680
Verify(exception.InnerException!.GetType() == typeof(AssertInconclusiveException));
685-
#if DEBUG
686681
Verify(exception.StackTraceInformation!.ErrorStackTrace.StartsWith(
687682
" at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests.Execution.TestMethodInfoTests.<>c.<TestMethodInfoInvokeWhenTestThrowsAssertInconclusiveReturnsExpectedResult>b__", StringComparison.Ordinal));
688-
#endif
689683
}
690684

691685
#endregion
@@ -831,11 +825,8 @@ public async Task TestMethodInfoInvokeWhenTestCleanupThrowsReturnsExpectedResult
831825
Verify(expectedErrorMessage == exception.Message);
832826
Verify(exception.InnerException!.GetType() == typeof(ArgumentException));
833827
Verify(exception.InnerException.InnerException!.GetType() == typeof(InvalidOperationException));
834-
835-
#if DEBUG
836828
Verify(exception.StackTraceInformation!.ErrorStackTrace.StartsWith(
837829
" at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests.Execution.TestMethodInfoTests.<>c.<TestMethodInfoInvokeWhenTestCleanupThrowsReturnsExpectedResult>b__", StringComparison.Ordinal));
838-
#endif
839830
}
840831

841832
public async Task TestMethodInfoInvokeWhenTestCleanupThrowsAssertInconclusiveReturnsExpectedResult()
@@ -859,10 +850,8 @@ public async Task TestMethodInfoInvokeWhenTestCleanupThrowsAssertInconclusiveRet
859850
Verify(exception.Outcome == UTF.UnitTestOutcome.Inconclusive);
860851
Verify(expectedErrorMessage == exception.Message);
861852
Verify(exception.InnerException!.GetType() == typeof(AssertInconclusiveException));
862-
#if DEBUG
863853
Verify(exception.StackTraceInformation!.ErrorStackTrace.StartsWith(
864-
" at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests.Execution.TestMethodInfoTests.<>c.<TestMethodInfoInvokeWhenTestCleanupThrowsAssertInconclusiveReturnsExpectedResult>b__", StringComparison.Ordinal));
865-
#endif
854+
" at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests.Execution.TestMethodInfoTests.<>c.<TestMethodInfoInvokeWhenTestCleanupThrowsAssertInconclusiveReturnsExpectedResult>b__", StringComparison.Ordinal));
866855
}
867856

868857
public async Task TestMethodInfoInvokeWhenTestCleanupThrowsAssertFailedReturnsExpectedResult()
@@ -886,10 +875,8 @@ public async Task TestMethodInfoInvokeWhenTestCleanupThrowsAssertFailedReturnsEx
886875
Verify(exception.Outcome == UTF.UnitTestOutcome.Failed);
887876
Verify(expectedErrorMessage == exception.Message);
888877
Verify(exception.InnerException!.GetType() == typeof(AssertFailedException));
889-
#if DEBUG
890878
Verify(exception.StackTraceInformation!.ErrorStackTrace.StartsWith(
891879
" at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests.Execution.TestMethodInfoTests.<>c.<TestMethodInfoInvokeWhenTestCleanupThrowsAssertFailedReturnsExpectedResult>b__", StringComparison.Ordinal));
892-
#endif
893880
}
894881

895882
public async Task TestMethodInfoInvokeShouldAppendErrorMessagesIfBothTestMethodAndTestCleanupThrows()
@@ -930,10 +917,8 @@ public async Task TestMethodInfoInvokeShouldAppendStackTraceInformationIfBothTes
930917

931918
Verify(result.Outcome == UTF.UnitTestOutcome.Failed);
932919
Verify(exception is not null);
933-
#if DEBUG
934920
Verify(((TestFailedException)exception.InnerExceptions[0]).StackTraceInformation!.ErrorStackTrace.Contains("Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests.Execution.TestMethodInfoTests.DummyTestClass.DummyTestMethod()"));
935921
Verify(((TestFailedException)exception.InnerExceptions[1]).StackTraceInformation!.ErrorStackTrace.Contains("Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests.Execution.TestMethodInfoTests.DummyTestClass.DummyTestCleanupMethod()"));
936-
#endif
937922
}
938923

939924
public async Task TestMethodInfoInvokeShouldSetOutcomeAsInconclusiveIfTestCleanupIsInconclusive()

test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/MSTestAdapter.PlatformServices.UnitTests.csproj

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,6 @@
1616
<DefineConstants>$(DefineConstants);WIN_UI</DefineConstants>
1717
</PropertyGroup>
1818

19-
<!-- Keep the property DebugType as some tests rely on specific pdb type -->
20-
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
21-
<DebugType>full</DebugType>
22-
</PropertyGroup>
23-
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
24-
<DebugType>pdbonly</DebugType>
25-
</PropertyGroup>
26-
2719
<ItemGroup>
2820
<ProjectReference Include="$(RepoRoot)src\TestFramework\TestFramework\TestFramework.csproj" Condition=" '$(IsNetCoreApp)' != 'true' " />
2921
<ProjectReference Include="$(RepoRoot)src\Adapter\MSTestAdapter.PlatformServices\MSTestAdapter.PlatformServices.csproj" Condition=" '$(TargetFramework)' != '$(NetStandardNetFrameworkHolder)' " />

test/Utilities/Automation.CLI/CLITestBase.e2e.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,6 @@ public void ValidateFailedTestsContain(bool validateStackTraceInfo, params strin
248248
test.Equals(f.DisplayName, StringComparison.Ordinal));
249249
testFound.Should().NotBeNull("Test '{0}' does not appear in failed tests list.", test);
250250

251-
#if DEBUG
252251
if (!validateStackTraceInfo)
253252
{
254253
continue;
@@ -261,7 +260,6 @@ public void ValidateFailedTestsContain(bool validateStackTraceInfo, params strin
261260
{
262261
testFound.ErrorStackTrace.Should().Contain(testMethodName, "No stack trace for failed test: {0}", test);
263262
}
264-
#endif
265263
}
266264
}
267265

0 commit comments

Comments
 (0)