@@ -52,7 +52,6 @@ public Collectors()
52
52
{
53
53
_buildConfiguration = TestUtils . GetAssemblyBuildConfiguration ( ) . ToString ( ) ;
54
54
_buildTargetFramework = TestUtils . GetAssemblyTargetFramework ( ) ;
55
-
56
55
}
57
56
58
57
protected string ? TestSDKVersion { get ; set ; }
@@ -81,20 +80,28 @@ private protected virtual void AssertCollectorsInjection(ClonedTemplateProject c
81
80
public void TestVsTest_Test ( )
82
81
{
83
82
using ClonedTemplateProject clonedTemplateProject = PrepareTemplateProject ( ) ;
84
- DotnetCli ( $ "test -c { _buildConfiguration } -f { _buildTargetFramework } \" { clonedTemplateProject . ProjectRootPath } \" --collect:\" XPlat Code Coverage\" --diag:{ Path . Combine ( clonedTemplateProject . ProjectRootPath , "log.txt" ) } ", out string _ , out string _ , clonedTemplateProject . ProjectRootPath ! ) ;
83
+ int cmdExitCode = DotnetCli ( $ "test -c { _buildConfiguration } -f { _buildTargetFramework } \" { clonedTemplateProject . ProjectRootPath } \" --collect:\" XPlat Code Coverage\" --diag:{ Path . Combine ( clonedTemplateProject . ProjectRootPath , "log.txt" ) } ", out string standardOutput , out string standardError , clonedTemplateProject . ProjectRootPath ! ) ;
85
84
// We don't have any result to check because tests and code to instrument are in same assembly so we need to pass
86
85
// IncludeTestAssembly=true we do it in other test
87
- Assert . Equal ( ( int ) CommandExitCodes . Success , DotnetCli ( $ "test -c { _buildConfiguration } -f { _buildTargetFramework } \" { clonedTemplateProject . ProjectRootPath } \" --collect:\" XPlat Code Coverage\" --diag:{ Path . Combine ( clonedTemplateProject . ProjectRootPath , "log.txt" ) } ", out string standardOutput , out string standardError , clonedTemplateProject . ProjectRootPath ! ) ) ;
86
+ if ( cmdExitCode != 0 )
87
+ {
88
+ //_output.WriteLine(standardError);
89
+ }
88
90
Assert . Contains ( "Passed!" , standardOutput ) ;
89
91
AssertCollectorsInjection ( clonedTemplateProject ) ;
92
+
90
93
}
91
94
92
95
[ Fact ]
93
96
public void TestVsTest_Test_Settings ( )
94
97
{
95
98
using ClonedTemplateProject clonedTemplateProject = PrepareTemplateProject ( ) ;
96
99
string runSettingsPath = AddCollectorRunsettingsFile ( clonedTemplateProject . ProjectRootPath ! ) ;
97
- Assert . Equal ( ( int ) CommandExitCodes . Success , DotnetCli ( $ "test -c { _buildConfiguration } -f { _buildTargetFramework } \" { clonedTemplateProject . ProjectRootPath } \" --collect:\" XPlat Code Coverage\" --settings \" { runSettingsPath } \" --diag:{ Path . Combine ( clonedTemplateProject . ProjectRootPath , "log.txt" ) } ", out string standardOutput , out string standardError ) ) ;
100
+ int cmdExitCode = DotnetCli ( $ "test -c { _buildConfiguration } -f { _buildTargetFramework } \" { clonedTemplateProject . ProjectRootPath } \" --collect:\" XPlat Code Coverage\" --settings \" { runSettingsPath } \" --diag:{ Path . Combine ( clonedTemplateProject . ProjectRootPath , "log.txt" ) } ", out string standardOutput , out string standardError ) ;
101
+ if ( cmdExitCode != 0 )
102
+ {
103
+ //_output.WriteLine(standardError);
104
+ }
98
105
Assert . Contains ( "Passed!" , standardOutput ) ;
99
106
AssertCoverage ( clonedTemplateProject ) ;
100
107
AssertCollectorsInjection ( clonedTemplateProject ) ;
@@ -105,10 +112,15 @@ public void TestVsTest_VsTest()
105
112
{
106
113
using ClonedTemplateProject clonedTemplateProject = PrepareTemplateProject ( ) ;
107
114
string runSettingsPath = AddCollectorRunsettingsFile ( clonedTemplateProject . ProjectRootPath ! ) ;
108
- Assert . Equal ( ( int ) CommandExitCodes . Success , DotnetCli ( $ "publish -c { _buildConfiguration } -f { _buildTargetFramework } { clonedTemplateProject . ProjectRootPath } ", out string standardOutput , out string standardError ) ) ;
115
+ int cmdExitCode = DotnetCli ( $ "publish -c { _buildConfiguration } -f { _buildTargetFramework } { clonedTemplateProject . ProjectRootPath } ", out string standardOutput , out string standardError ) ;
116
+ if ( cmdExitCode != 0 )
117
+ {
118
+ //_output.WriteLine(standardError);
119
+ }
120
+ Assert . Equal ( 0 , cmdExitCode ) ;
109
121
string publishedTestFile = clonedTemplateProject . GetFiles ( "*" + ClonedTemplateProject . AssemblyName + ".dll" ) . Single ( f => f . Contains ( "publish" ) ) ;
110
122
Assert . NotNull ( publishedTestFile ) ;
111
- Assert . Equal ( ( int ) CommandExitCodes . Success , DotnetCli ( $ "vstest \" { publishedTestFile } \" --collect:\" XPlat Code Coverage\" --diag:{ Path . Combine ( clonedTemplateProject . ProjectRootPath , "log.txt" ) } ", out standardOutput , out standardError ) ) ;
123
+ cmdExitCode = DotnetCli ( $ "vstest \" { publishedTestFile } \" --collect:\" XPlat Code Coverage\" --diag:{ Path . Combine ( clonedTemplateProject . ProjectRootPath , "log.txt" ) } ", out standardOutput , out standardError ) ;
112
124
// We don't have any result to check because tests and code to instrument are in same assembly so we need to pass
113
125
// IncludeTestAssembly=true we do it in other test
114
126
Assert . Contains ( "Passed!" , standardOutput ) ;
@@ -120,10 +132,15 @@ public void TestVsTest_VsTest_Settings()
120
132
{
121
133
using ClonedTemplateProject clonedTemplateProject = PrepareTemplateProject ( ) ;
122
134
string runSettingsPath = AddCollectorRunsettingsFile ( clonedTemplateProject . ProjectRootPath ! ) ;
123
- Assert . Equal ( ( int ) CommandExitCodes . Success , DotnetCli ( $ "publish -c { _buildConfiguration } -f { _buildTargetFramework } \" { clonedTemplateProject . ProjectRootPath } \" ", out string standardOutput , out string standardError ) ) ;
135
+ int cmdExitCode = DotnetCli ( $ "publish -c { _buildConfiguration } -f { _buildTargetFramework } \" { clonedTemplateProject . ProjectRootPath } \" ", out string standardOutput , out string standardError ) ;
136
+ if ( cmdExitCode != 0 )
137
+ {
138
+ //_output.WriteLine(standardError);
139
+ }
140
+ Assert . Equal ( 0 , cmdExitCode ) ;
124
141
string publishedTestFile = clonedTemplateProject . GetFiles ( "*" + ClonedTemplateProject . AssemblyName + ".dll" ) . Single ( f => f . Contains ( "publish" ) ) ;
125
142
Assert . NotNull ( publishedTestFile ) ;
126
- Assert . Equal ( ( int ) CommandExitCodes . Success , DotnetCli ( $ "vstest \" { publishedTestFile } \" --collect:\" XPlat Code Coverage\" --ResultsDirectory:\" { clonedTemplateProject . ProjectRootPath } \" /settings:\" { runSettingsPath } \" --diag:{ Path . Combine ( clonedTemplateProject . ProjectRootPath , "log.txt" ) } ", out standardOutput , out standardError ) ) ;
143
+ cmdExitCode = DotnetCli ( $ "vstest \" { publishedTestFile } \" --collect:\" XPlat Code Coverage\" --ResultsDirectory:\" { clonedTemplateProject . ProjectRootPath } \" /settings:\" { runSettingsPath } \" --diag:{ Path . Combine ( clonedTemplateProject . ProjectRootPath , "log.txt" ) } ", out standardOutput , out standardError ) ;
127
144
Assert . Contains ( "Passed!" , standardOutput ) ;
128
145
AssertCoverage ( clonedTemplateProject ) ;
129
146
AssertCollectorsInjection ( clonedTemplateProject ) ;
0 commit comments