This the same issue as #895 . I was able to implement the recommended solution to do a test setup that stubbed out the App Insights initialization but this isn't a great solution for my project.
Our approach is to build our APIs so we can enable App Insights through configuration where/as needed (by adding it in via our pom.xml), so we are trying to limit our app code to the Spring logging and instrumentation stack (SLF4J, Micrometer). This is working except in this case I need to add App Insights code to my tests need AI-specific code to work around this issue, breaking our approach.
Is it possible to put a null check before in this line to avoid this issue entirely? That would avoid going through the extra plumbing to avoid this issue in my tests.
I'm happy to make a PR on this if the team agrees with this approach.
The other approach would be a simple way to disable App Insights when running under test, but I don't see a way to do that.
This the same issue as #895 . I was able to implement the recommended solution to do a test setup that stubbed out the App Insights initialization but this isn't a great solution for my project.
Our approach is to build our APIs so we can enable App Insights through configuration where/as needed (by adding it in via our pom.xml), so we are trying to limit our app code to the Spring logging and instrumentation stack (SLF4J, Micrometer). This is working except in this case I need to add App Insights code to my tests need AI-specific code to work around this issue, breaking our approach.
Is it possible to put a null check before in this line to avoid this issue entirely? That would avoid going through the extra plumbing to avoid this issue in my tests.
I'm happy to make a PR on this if the team agrees with this approach.
The other approach would be a simple way to disable App Insights when running under test, but I don't see a way to do that.