@@ -6,6 +6,7 @@ namespace Microsoft.TestPlatform.AcceptanceTests
6
6
using Microsoft . VisualStudio . TestTools . UnitTesting ;
7
7
using System ;
8
8
using System . IO ;
9
+ using System . Text . RegularExpressions ;
9
10
using System . Xml ;
10
11
11
12
[ TestClass ]
@@ -41,7 +42,7 @@ public void BlameDataCollectorShouldGiveCorrectTestCaseName(RunnerInfo runnerInf
41
42
arguments = string . Concat ( arguments , $ " /ResultsDirectory:{ resultsDir } ") ;
42
43
this . InvokeVsTest ( arguments ) ;
43
44
44
- this . VaildateOutput ( ) ;
45
+ this . VaildateOutput ( "BlameUnitTestProject.UnitTest1.TestMethod2" ) ;
45
46
}
46
47
47
48
[ TestMethod ]
@@ -51,22 +52,59 @@ public void BlameDataCollectorShouldOutputDumpFile(RunnerInfo runnerInfo)
51
52
{
52
53
Environment . SetEnvironmentVariable ( "PROCDUMP_PATH" , Path . Combine ( this . testEnvironment . PackageDirectory , @"procdump\0.0.1\bin" ) ) ;
53
54
55
+ AcceptanceTestBase . SetTestEnvironment ( this . testEnvironment , runnerInfo ) ;
56
+ var assemblyPaths = this . BuildMultipleAssemblyPath ( "SimpleTestProject3.dll" ) . Trim ( '\" ' ) ;
57
+ var arguments = PrepareArguments ( assemblyPaths , this . GetTestAdapterPath ( ) , string . Empty , string . Empty , runnerInfo . InIsolationValue ) ;
58
+ arguments = string . Concat ( arguments , $ " /Blame:CollectDump") ;
59
+ arguments = string . Concat ( arguments , $ " /ResultsDirectory:{ resultsDir } ") ;
60
+ arguments = string . Concat ( arguments , " /testcasefilter:ExitWithStackoverFlow" ) ;
61
+ this . InvokeVsTest ( arguments ) ;
62
+
63
+ this . VaildateOutput ( "SampleUnitTestProject3.UnitTest1.ExitWithStackoverFlow" , validateDumpFile : true ) ;
64
+ }
65
+
66
+ [ TestMethod ]
67
+ [ NetFullTargetFrameworkDataSource ]
68
+ [ NetCoreTargetFrameworkDataSource ]
69
+ public void BlameDataCollectorShouldNotOutputDumpFileWhenNoCrashOccurs ( RunnerInfo runnerInfo )
70
+ {
71
+ Environment . SetEnvironmentVariable ( "PROCDUMP_PATH" , Path . Combine ( this . testEnvironment . PackageDirectory , @"procdump\0.0.1\bin" ) ) ;
72
+
54
73
AcceptanceTestBase . SetTestEnvironment ( this . testEnvironment , runnerInfo ) ;
55
- var assemblyPaths = this . GetAssetFullPath ( "BlameUnitTestProject .dll") ;
74
+ var assemblyPaths = this . BuildMultipleAssemblyPath ( "SimpleTestProject .dll") . Trim ( ' \" ' ) ;
56
75
var arguments = PrepareArguments ( assemblyPaths , this . GetTestAdapterPath ( ) , string . Empty , string . Empty , runnerInfo . InIsolationValue ) ;
57
76
arguments = string . Concat ( arguments , $ " /Blame:CollectDump") ;
58
77
arguments = string . Concat ( arguments , $ " /ResultsDirectory:{ resultsDir } ") ;
78
+ arguments = string . Concat ( arguments , " /testcasefilter:PassingTest" ) ;
79
+ this . InvokeVsTest ( arguments ) ;
80
+
81
+ StringAssert . DoesNotMatch ( this . StdOut , new Regex ( @"\.dmp" ) , "it should not collect a dump, because nothing crashed" ) ;
82
+ }
83
+
84
+ [ TestMethod ]
85
+ [ NetFullTargetFrameworkDataSource ]
86
+ [ NetCoreTargetFrameworkDataSource ]
87
+ public void BlameDataCollectorShouldOutputDumpFileWhenNoCrashOccursButCollectAlwaysIsEnabled ( RunnerInfo runnerInfo )
88
+ {
89
+ Environment . SetEnvironmentVariable ( "PROCDUMP_PATH" , Path . Combine ( this . testEnvironment . PackageDirectory , @"procdump\0.0.1\bin" ) ) ;
90
+
91
+ AcceptanceTestBase . SetTestEnvironment ( this . testEnvironment , runnerInfo ) ;
92
+ var assemblyPaths = this . BuildMultipleAssemblyPath ( "SimpleTestProject.dll" ) . Trim ( '\" ' ) ;
93
+ var arguments = PrepareArguments ( assemblyPaths , this . GetTestAdapterPath ( ) , string . Empty , string . Empty , runnerInfo . InIsolationValue ) ;
94
+ arguments = string . Concat ( arguments , $ " /Blame:CollectDump;CollectAlways=True") ;
95
+ arguments = string . Concat ( arguments , $ " /ResultsDirectory:{ resultsDir } ") ;
96
+ arguments = string . Concat ( arguments , " /testcasefilter:PassingTest" ) ;
59
97
this . InvokeVsTest ( arguments ) ;
60
98
61
- this . VaildateOutput ( true ) ;
99
+ StringAssert . Matches ( this . StdOut , new Regex ( @"\.dmp" ) , "it should collect dump, even if nothing crashed" ) ;
62
100
}
63
101
64
- private void VaildateOutput ( bool validateDumpFile = false )
102
+ private void VaildateOutput ( string testName , bool validateDumpFile = false )
65
103
{
66
104
bool isSequenceAttachmentReceived = false ;
67
105
bool isDumpAttachmentReceived = false ;
68
106
bool isValid = false ;
69
- this . StdErrorContains ( "BlameUnitTestProject.UnitTest1.TestMethod2" ) ;
107
+ this . StdErrorContains ( testName ) ;
70
108
this . StdOutputContains ( "Sequence_" ) ;
71
109
var resultFiles = Directory . GetFiles ( this . resultsDir , "*" , SearchOption . AllDirectories ) ;
72
110
0 commit comments