9
9
using Microsoft . Testing . Platform . CommandLine ;
10
10
using Microsoft . Testing . Platform . Extensions . Messages ;
11
11
using Microsoft . Testing . Platform . ServerMode ;
12
- using Microsoft . TestPlatform . AdapterUtilities ;
13
12
using Microsoft . TestPlatform . AdapterUtilities . ManagedNameUtilities ;
14
13
using Microsoft . VisualStudio . TestPlatform . ObjectModel ;
15
14
@@ -71,7 +70,7 @@ public static TestNode ToTestNode(this TestCase testCase, bool isTrxEnabled, INa
71
70
72
71
if ( ShouldAddVSTestProviderProperties ( namedFeatureCapability , commandLineOptions ) )
73
72
{
74
- CopyVSTestProviderProperties ( testCase . Properties , testNode , testCase . GetPropertyValue ) ;
73
+ CopyVSTestProviderProperties ( testNode , testCase ) ;
75
74
}
76
75
77
76
if ( testCase . CodeFilePath is not null )
@@ -109,34 +108,21 @@ private static void CopyCategoryAndTraits(TestObject testCaseOrResult, TestNode
109
108
}
110
109
}
111
110
112
- private static void CopyVSTestProviderProperties ( IEnumerable < TestProperty > testProperties , TestNode testNode , Func < TestProperty , object ? > getPropertyValue )
111
+ private static void CopyVSTestProviderProperties ( TestNode testNode , TestCase testCase )
113
112
{
114
- foreach ( TestProperty property in testProperties )
113
+ if ( testCase . Id is Guid testCaseId )
115
114
{
116
- // If vstestProvider is enabled (only known to be true for NUnit and Expecto so far), and we are running server mode in IDE (not dotnet test),
117
- // we add these stuff.
118
- // Once NUnit and Expecto allow us to move forward and remove vstestProvider, we can remove this logic and get rid of the whole vstestProvider capability.
119
- if ( property . Id == TestCaseProperties . Id . Id
120
- && getPropertyValue ( property ) is Guid testCaseId )
121
- {
122
- testNode . Properties . Add ( new SerializableKeyValuePairStringProperty ( "vstest.TestCase.Id" , testCaseId . ToString ( ) ) ) ;
123
- }
124
- else if ( property . Id == TestCaseProperties . FullyQualifiedName . Id
125
- && getPropertyValue ( property ) is string testCaseFqn )
126
- {
127
- testNode . Properties . Add ( new SerializableKeyValuePairStringProperty ( "vstest.TestCase.FullyQualifiedName" , testCaseFqn ) ) ;
128
- }
129
- else if ( property . Id == OriginalExecutorUriProperty . Id
130
- && getPropertyValue ( property ) is Uri originalExecutorUri )
131
- {
132
- testNode . Properties . Add ( new SerializableKeyValuePairStringProperty ( "vstest.original-executor-uri" , originalExecutorUri . AbsoluteUri ) ) ;
133
- }
134
- else if ( property . Id == HierarchyConstants . HierarchyPropertyId
135
- && getPropertyValue ( property ) is string [ ] testCaseHierarchy
136
- && testCaseHierarchy . Length == 4 )
137
- {
138
- testNode . Properties . Add ( new SerializableNamedArrayStringProperty ( "vstest.TestCase.Hierarchy" , testCaseHierarchy ) ) ;
139
- }
115
+ testNode . Properties . Add ( new SerializableKeyValuePairStringProperty ( "vstest.TestCase.Id" , testCaseId . ToString ( ) ) ) ;
116
+ }
117
+
118
+ if ( testCase . FullyQualifiedName is string testCaseFqn )
119
+ {
120
+ testNode . Properties . Add ( new SerializableKeyValuePairStringProperty ( "vstest.TestCase.FullyQualifiedName" , testCaseFqn ) ) ;
121
+ }
122
+
123
+ if ( testCase . GetPropertyValue ( OriginalExecutorUriProperty ) is Uri originalExecutorUri )
124
+ {
125
+ testNode . Properties . Add ( new SerializableKeyValuePairStringProperty ( "vstest.original-executor-uri" , originalExecutorUri . AbsoluteUri ) ) ;
140
126
}
141
127
}
142
128
@@ -149,15 +135,6 @@ public static TestNode ToTestNode(this TestResult testResult, bool isTrxEnabled,
149
135
150
136
CopyCategoryAndTraits ( testResult , testNode , isTrxEnabled ) ;
151
137
152
- bool addVSTestProviderProperties = ShouldAddVSTestProviderProperties ( namedFeatureCapability , commandLineOptions ) ;
153
- if ( addVSTestProviderProperties )
154
- {
155
- // TODO: This call might be unnecessary.
156
- // All the relevant properties should be on TestCase, not TestResult.
157
- // And properties on TestCase were already copied as part of ToTestNode call above.
158
- CopyVSTestProviderProperties ( testResult . Properties , testNode , testResult . GetPropertyValue ) ;
159
- }
160
-
161
138
testNode . AddOutcome ( testResult ) ;
162
139
163
140
if ( isTrxEnabled )
@@ -189,6 +166,7 @@ public static TestNode ToTestNode(this TestResult testResult, bool isTrxEnabled,
189
166
190
167
var standardErrorMessages = new List < string > ( ) ;
191
168
var standardOutputMessages = new List < string > ( ) ;
169
+ bool addVSTestProviderProperties = ShouldAddVSTestProviderProperties ( namedFeatureCapability , commandLineOptions ) ;
192
170
foreach ( TestResultMessage testResultMessage in testResult . Messages )
193
171
{
194
172
if ( testResultMessage . Category == TestResultMessage . StandardErrorCategory )
0 commit comments