@@ -2,6 +2,7 @@ import { TestConfiguration, TestPlan, TestPoint } from "azure-devops-node-api/in
22import { TestResultContextParameters } from "./TestResultContextParameters" ;
33import { TestResultContextBuilder } from "./TestResultContextBuilder" ;
44import { configAlias } from "./configAlias" ;
5+ import { TestPoint2 } from "../services/AdoWrapper" ;
56
67export class TestResultContext {
78
@@ -17,13 +18,17 @@ export class TestResultContext {
1718
1819 private readonly supportedTestConfigs : Map < string , TestConfiguration > ;
1920 private readonly testPoints : Map < number , TestPoint > ;
21+ private readonly testCases : Set < string > ;
22+ private readonly syncOutcomeAcrossSuites : boolean = false ;
2023
2124 constructor ( projectId : string , projectName : string , testPlan : TestPlan ) {
2225 this . projectId = projectId ;
2326 this . projectName = projectName ;
2427 this . testPlan = testPlan ;
2528 this . supportedTestConfigs = new Map < string , TestConfiguration > ( ) ;
2629 this . testPoints = new Map < number , TestPoint > ( ) ;
30+ this . testCases = new Set < string > ( ) ;
31+ this . syncOutcomeAcrossSuites = this . testPlan . testOutcomeSettings ?. syncOutcomeAcrossSuites ?? false ;
2732 }
2833
2934 addConfig ( config : TestConfiguration ) {
@@ -54,6 +59,22 @@ export class TestResultContext {
5459 }
5560
5661 addTestPoint ( point : TestPoint ) {
62+
63+ // as performance optimization, we can exclude test points that are duplicate test case references
64+ // when the test plan has the "sync outcome across suites" option enabled
65+ if ( this . syncOutcomeAcrossSuites ) {
66+ // logic to handle duplicate test points
67+ const testCaseId = ( point as TestPoint2 ) . testCaseReference . id ;
68+ if ( testCaseId ) {
69+ if ( this . testCases . has ( testCaseId . toString ( ) ) ) {
70+ // skip adding this test point as it's a duplicate reference to the same test case
71+ return ;
72+ }
73+ // add the test case ID to the set to track it
74+ this . testCases . add ( testCaseId . toString ( ) ) ;
75+ }
76+ }
77+
5778 this . testPoints . set ( point . id , point ) ;
5879 }
5980
@@ -91,4 +112,8 @@ export class TestResultContext {
91112 hasConfig ( name : string ) : boolean {
92113 return this . supportedTestConfigs . has ( name ) ;
93114 }
115+
116+ hasSyncTestOutcomeEnabled ( ) : boolean {
117+ return this . syncOutcomeAcrossSuites ;
118+ }
94119}
0 commit comments