File tree Expand file tree Collapse file tree 4 files changed +9
-10
lines changed
Adapter/MSTest.TestAdapter
TestFramework/TestFramework/Interfaces Expand file tree Collapse file tree 4 files changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -170,7 +170,7 @@ internal TestResult[] RunTestMethod()
170170 var parentStopwatch = Stopwatch . StartNew ( ) ;
171171 if ( _test . DataType == DynamicDataType . ITestDataSource )
172172 {
173- if ( ! string . IsNullOrEmpty ( _test . TestDataSourceIgnoreMessage ) )
173+ if ( _test . TestDataSourceIgnoreMessage is not null )
174174 {
175175 _testContext . SetOutcome ( UTF . UnitTestOutcome . Ignored ) ;
176176 return [ TestResult . CreateIgnoredResult ( _test . TestDataSourceIgnoreMessage ) ] ;
@@ -269,7 +269,7 @@ private bool TryExecuteFoldedDataDrivenTests(List<TestResult> results)
269269
270270 foreach ( UTF . ITestDataSource testDataSource in testDataSources )
271271 {
272- if ( testDataSource is ITestDataSourceIgnoreCapability { IgnoreMessage : { Length : > 0 } ignoreMessage } )
272+ if ( testDataSource is ITestDataSourceIgnoreCapability { IgnoreMessage : { } ignoreMessage } )
273273 {
274274 results . Add ( TestResult . CreateIgnoredResult ( ignoreMessage ) ) ;
275275 continue ;
Original file line number Diff line number Diff line change @@ -153,12 +153,7 @@ public string? DeclaringClassFullName
153153 /// Gets or sets the test data source ignore message.
154154 /// </summary>
155155 /// <remarks>
156- /// The test is ignored if this is set to non-null and non-empty string.
157- /// If set to empty string, the test is considered as not ignored.
158- /// In VSTest, when tests are expanded during discovery, we end up reading
159- /// this property as empty string, even though it was set to null.
160- /// (probably some serialization issue on VSTest side)
161- /// So, we treat null and empty string the same.
156+ /// The test is ignored if this is set to non-null.
162157 /// </remarks>
163158 internal string ? TestDataSourceIgnoreMessage { get ; set ; }
164159
Original file line number Diff line number Diff line change @@ -195,7 +195,11 @@ internal TestCase ToTestCase()
195195
196196 testCase . SetPropertyValue ( Constants . TestDynamicDataTypeProperty , ( int ) TestMethod . DataType ) ;
197197 testCase . SetPropertyValue ( Constants . TestDynamicDataProperty , data ) ;
198- testCase . SetPropertyValue ( Constants . TestDataSourceIgnoreMessageProperty , TestMethod . TestDataSourceIgnoreMessage ) ;
198+ // VSTest serialization doesn't handle null so instead don't set the property so that it's deserialized as null
199+ if ( TestMethod . TestDataSourceIgnoreMessage is not null )
200+ {
201+ testCase . SetPropertyValue ( Constants . TestDataSourceIgnoreMessageProperty , TestMethod . TestDataSourceIgnoreMessage ) ;
202+ }
199203 }
200204
201205 SetTestCaseId ( testCase , testFullName ) ;
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting;
99public interface ITestDataSourceIgnoreCapability
1010{
1111 /// <summary>
12- /// Gets or sets a reason to ignore the test data source. Setting the property to non-null and non-empty string value will ignore the test data source.
12+ /// Gets or sets a reason to ignore the test data source. Setting the property to non-null value will ignore the test data source.
1313 /// </summary>
1414 string ? IgnoreMessage { get ; set ; }
1515}
You can’t perform that action at this time.
0 commit comments