@@ -17,7 +17,8 @@ public partial class CLITestBase : TestContainer
17
17
{
18
18
private static VsTestConsoleWrapper s_vsTestConsoleWrapper ;
19
19
private DiscoveryEventsHandler _discoveryEventsHandler ;
20
- private RunEventsHandler _runEventsHandler ;
20
+
21
+ protected RunEventsHandler RunEventsHandler { get ; private set ; }
21
22
22
23
public CLITestBase ( )
23
24
{
@@ -46,17 +47,17 @@ public void InvokeVsTestForDiscovery(string[] sources, string runSettings = "")
46
47
/// <param name="sources">List of test assemblies.</param>
47
48
/// <param name="runSettings">Run settings for execution.</param>
48
49
/// <param name="testCaseFilter">Test Case filter for execution.</param>
49
- public void InvokeVsTestForExecution ( string [ ] sources , string runSettings = "" , string testCaseFilter = null )
50
+ public void InvokeVsTestForExecution ( string [ ] sources , string runSettings = "" , string testCaseFilter = null , string targetFramework = "" )
50
51
{
51
52
ExpandTestSourcePaths ( sources ) ;
52
53
53
- _runEventsHandler = new RunEventsHandler ( ) ;
54
- string runSettingXml = GetRunSettingXml ( runSettings , GetTestAdapterPath ( ) ) ;
54
+ RunEventsHandler = new RunEventsHandler ( ) ;
55
+ string runSettingXml = GetRunSettingXml ( runSettings , GetTestAdapterPath ( ) , targetFramework ) ;
55
56
56
- s_vsTestConsoleWrapper . RunTests ( sources , runSettingXml , new TestPlatformOptions { TestCaseFilter = testCaseFilter } , _runEventsHandler ) ;
57
- if ( _runEventsHandler . Errors . Any ( ) )
57
+ s_vsTestConsoleWrapper . RunTests ( sources , runSettingXml , new TestPlatformOptions { TestCaseFilter = testCaseFilter } , RunEventsHandler ) ;
58
+ if ( RunEventsHandler . Errors . Any ( ) )
58
59
{
59
- throw new Exception ( $ "Run failed with { _runEventsHandler . Errors . Count } errors:{ Environment . NewLine } { string . Join ( Environment . NewLine , _runEventsHandler . Errors ) } ") ;
60
+ throw new Exception ( $ "Run failed with { RunEventsHandler . Errors . Count } errors:{ Environment . NewLine } { string . Join ( Environment . NewLine , RunEventsHandler . Errors ) } ") ;
60
61
}
61
62
}
62
63
@@ -104,7 +105,7 @@ public void ValidatePassedTests(params string[] passedTests)
104
105
public void ValidatePassedTestsCount ( int expectedPassedTestsCount )
105
106
{
106
107
// Make sure only expected number of tests passed and not more.
107
- Assert . AreEqual ( expectedPassedTestsCount , _runEventsHandler . PassedTests . Count ) ;
108
+ Assert . AreEqual ( expectedPassedTestsCount , RunEventsHandler . PassedTests . Count ) ;
108
109
}
109
110
110
111
/// <summary>
@@ -129,7 +130,7 @@ public void ValidateFailedTests(string source, params string[] failedTests)
129
130
public void ValidateFailedTestsCount ( int expectedFailedTestsCount )
130
131
{
131
132
// Make sure only expected number of tests failed and not more.
132
- Assert . AreEqual ( expectedFailedTestsCount , _runEventsHandler . FailedTests . Count ) ;
133
+ Assert . AreEqual ( expectedFailedTestsCount , RunEventsHandler . FailedTests . Count ) ;
133
134
}
134
135
135
136
/// <summary>
@@ -140,7 +141,7 @@ public void ValidateFailedTestsCount(int expectedFailedTestsCount)
140
141
public void ValidateSkippedTests ( params string [ ] skippedTests )
141
142
{
142
143
// Make sure only expected number of tests skipped and not more.
143
- Assert . AreEqual ( skippedTests . Length , _runEventsHandler . SkippedTests . Count ) ;
144
+ Assert . AreEqual ( skippedTests . Length , RunEventsHandler . SkippedTests . Count ) ;
144
145
145
146
ValidateSkippedTestsContain ( skippedTests ) ;
146
147
}
@@ -153,9 +154,9 @@ public void ValidateSkippedTests(params string[] skippedTests)
153
154
[ MethodImpl ( MethodImplOptions . NoInlining | MethodImplOptions . NoOptimization ) ]
154
155
public void ValidatePassedTestsContain ( params string [ ] passedTests )
155
156
{
156
- var passedTestResults = _runEventsHandler . PassedTests ;
157
- var failedTestResults = _runEventsHandler . FailedTests ;
158
- var skippedTestsResults = _runEventsHandler . SkippedTests ;
157
+ var passedTestResults = RunEventsHandler . PassedTests ;
158
+ var failedTestResults = RunEventsHandler . FailedTests ;
159
+ var skippedTestsResults = RunEventsHandler . SkippedTests ;
159
160
160
161
foreach ( var test in passedTests )
161
162
{
@@ -195,7 +196,7 @@ public void ValidateFailedTestsContain(string source, bool validateStackTraceInf
195
196
{
196
197
foreach ( var test in failedTests )
197
198
{
198
- var testFound = _runEventsHandler . FailedTests . FirstOrDefault ( f => test . Equals ( f . TestCase ? . FullyQualifiedName ) ||
199
+ var testFound = RunEventsHandler . FailedTests . FirstOrDefault ( f => test . Equals ( f . TestCase ? . FullyQualifiedName ) ||
199
200
test . Equals ( f . DisplayName ) ) ;
200
201
Assert . IsNotNull ( testFound , "Test '{0}' does not appear in failed tests list." , test ) ;
201
202
@@ -223,7 +224,7 @@ public void ValidateSkippedTestsContain(params string[] skippedTests)
223
224
{
224
225
foreach ( var test in skippedTests )
225
226
{
226
- var testFound = _runEventsHandler . SkippedTests . Any ( s => test . Equals ( s . TestCase . FullyQualifiedName ) ||
227
+ var testFound = RunEventsHandler . SkippedTests . Any ( s => test . Equals ( s . TestCase . FullyQualifiedName ) ||
227
228
test . Equals ( s . DisplayName ) ) ;
228
229
Assert . IsTrue ( testFound , "Test '{0}' does not appear in skipped tests list." , test ) ;
229
230
}
@@ -232,8 +233,8 @@ public void ValidateSkippedTestsContain(params string[] skippedTests)
232
233
public void ValidateTestRunTime ( int thresholdTime )
233
234
{
234
235
Assert . IsTrue (
235
- _runEventsHandler . ElapsedTimeInRunningTests >= 0 && _runEventsHandler . ElapsedTimeInRunningTests < thresholdTime ,
236
- $ "Test Run was expected to not exceed { thresholdTime } but it took { _runEventsHandler . ElapsedTimeInRunningTests } ") ;
236
+ RunEventsHandler . ElapsedTimeInRunningTests >= 0 && RunEventsHandler . ElapsedTimeInRunningTests < thresholdTime ,
237
+ $ "Test Run was expected to not exceed { thresholdTime } but it took { RunEventsHandler . ElapsedTimeInRunningTests } ") ;
237
238
}
238
239
239
240
/// <summary>
0 commit comments