You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ParameterizedTest with name pattern specified relies on Locale.getDefault(). This results in test names that possibly changing:
public class SimplifiedExample
{
@BeforeAll
static void before_all() { Locale.setDefault(Locale.US); }
@BeforeEach
void before_each() { Locale.setDefault(Locale.UK); }
@ParameterizedTest(name = "{0,number,currency}")
@ValueSource(ints = { 1_000, 2_000 })
void test1(int a)
{
// Test names with locale change:
// $1,000.00
// £2,000.00
}
}
It seems the first MessageFormat is created after the call to BeforeAll and before the call to BeforeEach. As the Locale cannot be set for a ParameterizedTest your stuck with whatever the environments current default is.
It seems that the limited formatting is already down the "rabbit hole" @marcphilipp#1154
Add to this that the arguments formatted are those supplied by the provider before implicit or explicit conversion and not those supplied to the method then formatting is not very useful and certainly breaks the principle of least surprise.
As such I propose that formatting should support only place holders '{0} {1} etc...' until such time that @sbrannen#1154 support for formatting API is added.
The text was updated successfully, but these errors were encountered:
Team decision: As documented, we pass the format expression to MessageFormat which uses the default locale. Thus, this works as designed and documented. If you run your tests on machines with different locales and want consistent test names, please set the JDK's locale via the standard system property. If you need to test with different locales, you could use Pioneer's @DefaultLocale.
ParameterizedTest
with name pattern specified relies onLocale.getDefault()
. This results in test names that possibly changing:It seems the first
MessageFormat
is created after the call toBeforeAll
and before the call toBeforeEach
. As theLocale
cannot be set for aParameterizedTest
your stuck with whatever the environments current default is.It seems that the limited formatting is already down the "rabbit hole" @marcphilipp #1154
Add to this that the arguments formatted are those supplied by the provider before implicit or explicit conversion and not those supplied to the method then formatting is not very useful and certainly breaks the principle of least surprise.
As such I propose that formatting should support only place holders '{0} {1} etc...' until such time that @sbrannen #1154 support for formatting API is added.
The text was updated successfully, but these errors were encountered: