File tree 4 files changed +9
-10
lines changed
Adapter/MSTest.TestAdapter
TestFramework/TestFramework/Interfaces
4 files changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -170,7 +170,7 @@ internal TestResult[] RunTestMethod()
170
170
var parentStopwatch = Stopwatch . StartNew ( ) ;
171
171
if ( _test . DataType == DynamicDataType . ITestDataSource )
172
172
{
173
- if ( ! string . IsNullOrEmpty ( _test . TestDataSourceIgnoreMessage ) )
173
+ if ( _test . TestDataSourceIgnoreMessage is not null )
174
174
{
175
175
_testContext . SetOutcome ( UTF . UnitTestOutcome . Ignored ) ;
176
176
return [ TestResult . CreateIgnoredResult ( _test . TestDataSourceIgnoreMessage ) ] ;
@@ -269,7 +269,7 @@ private bool TryExecuteFoldedDataDrivenTests(List<TestResult> results)
269
269
270
270
foreach ( UTF . ITestDataSource testDataSource in testDataSources )
271
271
{
272
- if ( testDataSource is ITestDataSourceIgnoreCapability { IgnoreMessage : { Length : > 0 } ignoreMessage } )
272
+ if ( testDataSource is ITestDataSourceIgnoreCapability { IgnoreMessage : { } ignoreMessage } )
273
273
{
274
274
results . Add ( TestResult . CreateIgnoredResult ( ignoreMessage ) ) ;
275
275
continue ;
Original file line number Diff line number Diff line change @@ -153,12 +153,7 @@ public string? DeclaringClassFullName
153
153
/// Gets or sets the test data source ignore message.
154
154
/// </summary>
155
155
/// <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.
162
157
/// </remarks>
163
158
internal string ? TestDataSourceIgnoreMessage { get ; set ; }
164
159
Original file line number Diff line number Diff line change @@ -195,7 +195,11 @@ internal TestCase ToTestCase()
195
195
196
196
testCase . SetPropertyValue ( Constants . TestDynamicDataTypeProperty , ( int ) TestMethod . DataType ) ;
197
197
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
+ }
199
203
}
200
204
201
205
SetTestCaseId ( testCase , testFullName ) ;
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting;
9
9
public interface ITestDataSourceIgnoreCapability
10
10
{
11
11
/// <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.
13
13
/// </summary>
14
14
string ? IgnoreMessage { get ; set ; }
15
15
}
You can’t perform that action at this time.
0 commit comments