Injecting external libraries in system under test during testing is becoming a challenging

I just wanted to share this issue during the call, but I couldn’t because my computer had some sound issues.
But the actual problem is here:

In configuration, we register the packages to scan in this way:

From there, test cases on different modules such as patient, person, patientType, and test run smoothly because they are depending on internal dependencies.

But when it comes to other modules such organization which depends on external libraries, it becomes a great challenge because the OrganizationImportService under the organization package contains an FhirContext dependency, which is an external library. The fact that it’s an external library leads to dependency injection failure during tests execution, and the error below is thrown.

`Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘ca.uhn.fhir.context.FhirContext’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
can someone guide to know where that ca.uhn.fhir.context.FhirContext is configured?`

Anyone to help !

In the above configuartion ,all external Autowired beans are excluded including fhir related beans

1 Like

ooooooh I got you @Moses_Mutesasira , now I can understand that we don’t have to rely only on basePackages inclusion, we should also check in external libraries exclusion.

Thank you @Moses_Mutesasira . we are now on the same page.