Skip to content

Generate Test Clients during test compilation #585

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

Merged
merged 9 commits into from
Mar 26, 2025

Conversation

SentryMan
Copy link
Collaborator

@SentryMan SentryMan commented Mar 26, 2025

mostly resolves #584 with a few caveats

  • won't generate client methods for controllers with a Context parameter
  • won't generate for controllers that use inherited API

There are some bugs to work out using this approach. It seems that during test compilation it causes the classes to get recompiled so inject complains with errors like No dependency provided for org.example.web.myapp.WebController on org.example.web.myapp.WebController$Route

@SentryMan
Copy link
Collaborator Author

It turns out that even trying the traditional way with an annotation doesn't work either. Might have to get creative

@SentryMan
Copy link
Collaborator Author

Figured it out by writing the source into a text file in target during compilation then loading and writing directly during test compilation.

@SentryMan SentryMan requested a review from rbygrave March 26, 2025 19:04
@SentryMan SentryMan marked this pull request as ready for review March 26, 2025 19:04
@SentryMan
Copy link
Collaborator Author

let me actually write a test first

@rbygrave
Copy link
Contributor

writing the source into a text file in target during compilation then loading ...

That was cunning!! Well done!!

@SentryMan SentryMan requested a review from rbygrave March 26, 2025 21:18
@SentryMan SentryMan merged commit 6571d95 into avaje:master Mar 26, 2025
6 checks passed
@SentryMan SentryMan deleted the test-client branch March 26, 2025 22:04
@rbygrave rbygrave added this to the 3.2 milestone Mar 26, 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.

New annotation to generate a test http client interface for a Controller
2 participants