@@ -573,29 +573,38 @@ export async function runTests(libProject?: LibertyProject | undefined): Promise
573573// open surefire, failsafe, or gradle test report
574574export async function openReport ( reportType : string , libProject ?: LibertyProject | undefined ) : Promise < void > {
575575 if ( libProject !== undefined ) {
576- const path = Path . dirname ( libProject . getPath ( ) ) ;
576+ // Resolve the target project (handles aggregators with multiple Liberty children)
577+ const projectProvider : ProjectProvider = ProjectProvider . getInstance ( ) ;
578+ const targetProject = await projectProvider . resolveCommandTarget ( libProject , localize ( "command.view.test.report" ) ) ;
579+
580+ if ( targetProject === undefined ) {
581+ // User cancelled or no valid target found
582+ return ;
583+ }
584+
585+ const path = Path . dirname ( targetProject . getPath ( ) ) ;
577586 if ( path !== undefined ) {
578587 let report : any ;
579588 let reportTypeLabel = reportType ;
580589 if ( reportType === "gradle" ) {
581590 reportTypeLabel = "test" ;
582591 }
583592 let showErrorMessage : boolean = true ;
584- if ( libProject . getContextValue ( ) === LIBERTY_MAVEN_PROJECT || libProject . getContextValue ( ) === LIBERTY_MAVEN_PROJECT_CONTAINER ) {
593+ if ( targetProject . getContextValue ( ) === LIBERTY_MAVEN_PROJECT || targetProject . getContextValue ( ) === LIBERTY_MAVEN_PROJECT_CONTAINER ) {
585594 report = getReportFile ( path , "reports" , reportType + ".html" ) ;
586595 // show the error message only if both "reports" and "site" dirs do not contain the test reports
587596 // set to false since this will be the first location checked
588- showErrorMessage = false ;
589- if ( ! await checkReportAndDisplay ( report , reportType , reportTypeLabel , libProject , showErrorMessage ) ) {
597+ showErrorMessage = false ;
598+ if ( ! await checkReportAndDisplay ( report , reportType , reportTypeLabel , targetProject , showErrorMessage ) ) {
590599 report = getReportFile ( path , "site" , reportType + "-report.html" ) ;
591600 // show the error message only if both "reports" and "site" dirs do not contain the test reports
592601 // set to true since this will be the second location checked
593- showErrorMessage = true ;
594- await checkReportAndDisplay ( report , reportType , reportTypeLabel , libProject , showErrorMessage ) ;
602+ showErrorMessage = true ;
603+ await checkReportAndDisplay ( report , reportType , reportTypeLabel , targetProject , showErrorMessage ) ;
595604 }
596- } else if ( libProject . getContextValue ( ) === LIBERTY_GRADLE_PROJECT || libProject . getContextValue ( ) === LIBERTY_GRADLE_PROJECT_CONTAINER ) {
597- report = await getGradleTestReport ( libProject . path , path ) ;
598- await checkReportAndDisplay ( report , reportType , reportTypeLabel , libProject , showErrorMessage ) ;
605+ } else if ( targetProject . getContextValue ( ) === LIBERTY_GRADLE_PROJECT || targetProject . getContextValue ( ) === LIBERTY_GRADLE_PROJECT_CONTAINER ) {
606+ report = await getGradleTestReport ( targetProject . path , path ) ;
607+ await checkReportAndDisplay ( report , reportType , reportTypeLabel , targetProject , showErrorMessage ) ;
599608 }
600609 }
601610 } else if ( ProjectProvider . getInstance ( ) && reportType ) {
0 commit comments