Allow tests to be written with Java 17 or 21 for access to text blocks
timtebeek opened this issue · comments
What problem are you trying to solve?
Right now our tests use resource files for in and outputs, but these mean there's a disconnect between a test method and what it actually verifies.
Describe the solution you'd like
With text blocks and JavaFileObjects.forSourceString
we can instead adopt a test style similar to what we use elsewhere in OpenRewrite. That should help familiarity, and seeing at a glance what a test verifies.
static Compilation compileSource(String fqn, @Language("java") String source, TypeAwareProcessor processor) {
return compileResource(JavaFileObjects.forSourceString(fqn, source), processor);
}
Additional context
The compileSource
method above as already been added in
My quick attempts so far have failed to produce a working setup with Gradle; something to do with toolchains that I think I'm close to, but some help would be appreciated to get this in.
Through #57 there's now already two methods that can take a String input.