-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Introduce ConversionService
in junit-platform-commons
#4219
base: main
Are you sure you want to change the base?
Conversation
There is plenty of work to do 🙃 The current highlights:
Any feedback would be highly appreciated! |
c31ca83
to
b19cba8
Compare
b19cba8
to
a7a8aa3
Compare
3304ad5
to
c886b7a
Compare
junit-jupiter-params/src/main/java/org/junit/jupiter/params/converter/ArgumentConverter.java
Show resolved
Hide resolved
c886b7a
to
7ea91b8
Compare
Thanks for the draft! 👍 The tests are failing due to:
That's because
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks very promising! 👍
...m-commons/src/main/java/org/junit/platform/commons/support/conversion/ConversionSupport.java
Show resolved
Hide resolved
...m-commons/src/main/java/org/junit/platform/commons/support/conversion/ConversionSupport.java
Show resolved
Hide resolved
...m-commons/src/main/java/org/junit/platform/commons/support/conversion/ConversionSupport.java
Outdated
Show resolved
Hide resolved
// FIXME move/copy next three lines to canConvert? | ||
Class<?> targetTypeToUse = toWrapperType(targetType); | ||
Optional<StringToObjectConverter> converter = stringToObjectConverters.stream().filter( | ||
candidate -> candidate.canConvertTo(targetTypeToUse)).findFirst(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was also wondering about that but am not sure. I guess we should only move it if it makes things simpler or helps us produce a better error message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I found a good reason to move the logic to canConvert
, I'll dig a bit more later.
|
||
import org.junit.platform.commons.support.conversion.TypedConversionService; | ||
|
||
// FIXME delete |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would make a good test case, though. We have existing tests that register services for tests using an extra class loader:
junit5/platform-tests/src/test/java/org/junit/platform/launcher/core/LauncherFactoryTests.java
Lines 353 to 366 in 16c6f72
private static void withTestServices(Runnable runnable) { | |
var current = Thread.currentThread().getContextClassLoader(); | |
var url = LauncherFactoryTests.class.getClassLoader().getResource("testservices/"); | |
try (var classLoader = new URLClassLoader(new URL[] { url }, current)) { | |
Thread.currentThread().setContextClassLoader(classLoader); | |
runnable.run(); | |
} | |
catch (IOException e) { | |
throw new UncheckedIOException(e); | |
} | |
finally { | |
Thread.currentThread().setContextClassLoader(current); | |
} | |
} |
We could generalize and move that method to a test utility class (e.g. in junit-jupiter-api/src/testFixtures
) so it can be reused here.
When you add that, you'll also have to add it to |
2e17c2b
to
0c2faa7
Compare
I've been lagging behind with this one but I should be able to spend time on it in the upcoming weekend. |
0c2faa7
to
098c972
Compare
Overview
Locale
argument conversion not settinglanguage
andcountry
properly #3141I hereby agree to the terms of the JUnit Contributor License Agreement.
Definition of Done
@API
annotations