Skip to content

Fix java-http-client tests #14034

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

jaydeluca
Copy link
Member

While working on #13468 I noticed these tests weren't emitting metrics like I was expecting. It seems that at least for me locally, these tests are failing to run but not being counted as a failed test run.

I found that running ./gradlew :instrumentation:java-http-client:javaagent:test resulted in:

(2) [WARNING] @Nested class 'io.opentelemetry.javaagent.instrumentation.javahttpclient.JavaHttpClientTest$Http2ClientTest' must not be static. It will not be executed.
    Source: ClassSource [className = 'io.opentelemetry.javaagent.instrumentation.javahttpclient.JavaHttpClientTest$Http2ClientTest', filePosition = null]
            at io.opentelemetry.javaagent.instrumentation.javahttpclient.JavaHttpClientTest$Http2ClientTest.<no-method>(SourceFile:0)

@jaydeluca jaydeluca requested a review from a team as a code owner June 13, 2025 20:16
@laurit
Copy link
Contributor

laurit commented Jun 13, 2025

Probably stopped working with the latest junit update. The same test is also present in library module. Did you consider just removing the static from the nested class? If removing static doesn't work the we should also test the other @Nested tests.

@jaydeluca
Copy link
Member Author

removing static does not fix it, although it makes that particular error message go away. It just silently doesn't run any tests. I will take a look at other tests that might use nested

@@ -22,37 +20,4 @@ public abstract class JavaHttpClientTest extends AbstractJavaHttpClientTest {
protected HttpClient configureHttpClient(HttpClient httpClient) {
return httpClient;
}

@Nested
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested making these classes non-static, but then I hit circular dependency with the inner class extending its enclosing class

If we keep the classes static and remove the @Nested annotation, the tests run, but I believe that we risk test isolation problems

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nested tests could be made to work with #14043 Honestly I'm not sure which I like better.

@laurit
Copy link
Contributor

laurit commented Jun 16, 2025

resolved with #14043

@laurit laurit closed this Jun 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants