1313import static org .assertj .core .api .Assertions .assertThat ;
1414import static org .junit .jupiter .testkit .JUnitJupiterTestKit .executeTestClass ;
1515import static org .junit .jupiter .testkit .JUnitJupiterTestKit .executeTestMethod ;
16- import static org .junit .jupiter .testkit .assertion .JUnitJupiterAssert .assertThat ;
16+ import static org .junit .platform .testkit .engine .EventConditions .finishedWithFailure ;
17+ import static org .junit .platform .testkit .engine .TestExecutionResultConditions .instanceOf ;
18+ import static org .junit .platform .testkit .engine .TestExecutionResultConditions .message ;
1719
1820import java .util .Locale ;
1921
@@ -108,7 +110,7 @@ void setsLanguageAndCountryAndVariant() {
108110 void shouldExecuteTestsWithConfiguredLocale () {
109111 ExecutionResults results = executeTestClass (ClassLevelTestCases .class );
110112
111- assertThat ( results ). hasNumberOfSucceededTests ( 2 );
113+ results . testEvents (). assertThatEvents (). haveExactly ( 2 , null );
112114 }
113115
114116 @ DefaultLocale (language = "fr" , country = "FR" )
@@ -228,8 +230,8 @@ void shouldFailWhenNothingIsConfigured() {
228230 ExecutionResults results = executeTestMethod (MethodLevelInitializationFailureTestCases .class ,
229231 "shouldFailMissingConfiguration" );
230232
231- assertThat ( results ). hasSingleFailedTest ().withExceptionInstanceOf (
232- ExtensionConfigurationException .class );
233+ results . testEvents (). assertThatEvents ().haveExactly ( 1 ,
234+ finishedWithFailure ( instanceOf ( ExtensionConfigurationException .class )) );
233235 }
234236
235237 @ Test
@@ -238,8 +240,8 @@ void shouldFailWhenVariantIsSetButCountryIsNot() {
238240 ExecutionResults results = executeTestMethod (MethodLevelInitializationFailureTestCases .class ,
239241 "shouldFailMissingCountry" );
240242
241- assertThat ( results ). hasSingleFailedTest ().withExceptionInstanceOf (
242- ExtensionConfigurationException .class );
243+ results . testEvents (). assertThatEvents ().haveExactly ( 1 ,
244+ finishedWithFailure ( instanceOf ( ExtensionConfigurationException .class )) );
243245 }
244246
245247 @ Test
@@ -248,8 +250,8 @@ void shouldFailWhenLanguageTagAndLanguageIsSet() {
248250 ExecutionResults results = executeTestMethod (MethodLevelInitializationFailureTestCases .class ,
249251 "shouldFailLanguageTagAndLanguage" );
250252
251- assertThat ( results ). hasSingleFailedTest ().withExceptionInstanceOf (
252- ExtensionConfigurationException .class );
253+ results . testEvents (). assertThatEvents ().haveExactly ( 1 ,
254+ finishedWithFailure ( instanceOf ( ExtensionConfigurationException .class )) );
253255 }
254256
255257 @ Test
@@ -258,8 +260,8 @@ void shouldFailWhenLanguageTagAndCountryIsSet() {
258260 ExecutionResults results = executeTestMethod (MethodLevelInitializationFailureTestCases .class ,
259261 "shouldFailLanguageTagAndCountry" );
260262
261- assertThat ( results ). hasSingleFailedTest ().withExceptionInstanceOf (
262- ExtensionConfigurationException .class );
263+ results . testEvents (). assertThatEvents ().haveExactly ( 1 ,
264+ finishedWithFailure ( instanceOf ( ExtensionConfigurationException .class )) );
263265 }
264266
265267 @ Test
@@ -268,8 +270,8 @@ void shouldFailWhenLanguageTagAndVariantIsSet() {
268270 ExecutionResults results = executeTestMethod (MethodLevelInitializationFailureTestCases .class ,
269271 "shouldFailLanguageTagAndVariant" );
270272
271- assertThat ( results ). hasSingleFailedTest ().withExceptionInstanceOf (
272- ExtensionConfigurationException .class );
273+ results . testEvents (). assertThatEvents ().haveExactly ( 1 ,
274+ finishedWithFailure ( instanceOf ( ExtensionConfigurationException .class )) );
273275 }
274276
275277 @ Test
@@ -278,8 +280,8 @@ void shouldFailIfNoValidBCP47VariantIsSet() {
278280 ExecutionResults results = executeTestMethod (MethodLevelInitializationFailureTestCases .class ,
279281 "shouldFailNoValidBCP47Variant" );
280282
281- assertThat ( results ). hasSingleFailedTest ().withExceptionInstanceOf (
282- ExtensionConfigurationException .class );
283+ results . testEvents (). assertThatEvents ().haveExactly ( 1 ,
284+ finishedWithFailure ( instanceOf ( ExtensionConfigurationException .class )) );
283285 }
284286
285287 }
@@ -293,8 +295,8 @@ class ClassLevel {
293295 void shouldFailWhenVariantIsSetButCountryIsNot () {
294296 ExecutionResults results = executeTestClass (ClassLevelInitializationFailureTestCases .class );
295297
296- assertThat ( results ). hasSingleFailedTest ().withExceptionInstanceOf (
297- ExtensionConfigurationException .class );
298+ results . testEvents (). assertThatEvents ().haveExactly ( 1 ,
299+ finishedWithFailure ( instanceOf ( ExtensionConfigurationException .class )) );
298300 }
299301
300302 }
@@ -378,8 +380,9 @@ void canUseProvider() {
378380 void providerReturnsNull () {
379381 ExecutionResults results = executeTestMethod (BadProviderTestCases .class , "returnsNull" );
380382
381- assertThat (results ).hasSingleFailedTest ().withExceptionInstanceOf (
382- NullPointerException .class ).hasMessageContaining ("LocaleProvider instance returned with null" );
383+ results .testEvents ().assertThatEvents ().haveExactly (1 ,
384+ finishedWithFailure (instanceOf (NullPointerException .class ),
385+ message (it -> it .contains ("LocaleProvider instance returned with null" ))));
383386 }
384387
385388 @ Test
@@ -388,9 +391,9 @@ void providerReturnsNull() {
388391 void mutuallyExclusiveWithValue () {
389392 ExecutionResults results = executeTestMethod (BadProviderTestCases .class , "mutuallyExclusiveWithValue" );
390393
391- assertThat ( results ). hasSingleFailedTest ().withExceptionInstanceOf (
392- ExtensionConfigurationException .class ). hasMessageContaining (
393- "can only be used with language tag if language, country, variant and provider are not set" );
394+ results . testEvents (). assertThatEvents ().haveExactly ( 1 ,
395+ finishedWithFailure ( instanceOf ( ExtensionConfigurationException .class ), message ( it -> it . contains (
396+ "can only be used with a provider if value, language, country and variant are not set." ))) );
394397 }
395398
396399 @ Test
@@ -399,9 +402,9 @@ void mutuallyExclusiveWithValue() {
399402 void mutuallyExclusiveWithLanguage () {
400403 ExecutionResults results = executeTestMethod (BadProviderTestCases .class , "mutuallyExclusiveWithLanguage" );
401404
402- assertThat ( results ). hasSingleFailedTest ().withExceptionInstanceOf (
403- ExtensionConfigurationException .class ). hasMessageContaining (
404- "can only be used with language tag if provider is not set" );
405+ results . testEvents (). assertThatEvents ().haveExactly ( 1 ,
406+ finishedWithFailure ( instanceOf ( ExtensionConfigurationException .class ),
407+ message ( it -> it . contains ( "can only be used with language tag if provider is not set." ))) );
405408 }
406409
407410 @ Test
@@ -410,9 +413,9 @@ void mutuallyExclusiveWithLanguage() {
410413 void mutuallyExclusiveWithCountry () {
411414 ExecutionResults results = executeTestMethod (BadProviderTestCases .class , "mutuallyExclusiveWithCountry" );
412415
413- assertThat ( results ). hasSingleFailedTest ().withExceptionInstanceOf (
414- ExtensionConfigurationException .class ). hasMessageContaining (
415- "can only be used with a provider if value, language, country and variant are not set." );
416+ results . testEvents (). assertThatEvents ().haveExactly ( 1 ,
417+ finishedWithFailure ( instanceOf ( ExtensionConfigurationException .class ), message ( it -> it . contains (
418+ "can only be used with a provider if value, language, country and variant are not set." )))) ;
416419 }
417420
418421 @ Test
@@ -421,9 +424,9 @@ void mutuallyExclusiveWithCountry() {
421424 void mutuallyExclusiveWithVariant () {
422425 ExecutionResults results = executeTestMethod (BadProviderTestCases .class , "mutuallyExclusiveWithVariant" );
423426
424- assertThat ( results ). hasSingleFailedTest ().withExceptionInstanceOf (
425- ExtensionConfigurationException .class ). hasMessageContaining (
426- "can only be used with a provider if value, language, country and variant are not set." );
427+ results . testEvents (). assertThatEvents ().haveExactly ( 1 ,
428+ finishedWithFailure ( instanceOf ( ExtensionConfigurationException .class ), message ( it -> it . contains (
429+ "can only be used with a provider if value, language, country and variant are not set." )))) ;
427430 }
428431
429432 @ Test
@@ -432,9 +435,9 @@ void mutuallyExclusiveWithVariant() {
432435 void badConstructor () {
433436 ExecutionResults results = executeTestMethod (BadProviderTestCases .class , "badConstructor" );
434437
435- assertThat ( results ). hasSingleFailedTest ().withExceptionInstanceOf (
436- ExtensionConfigurationException .class ). hasMessageContaining (
437- "could not be constructed because of an exception" );
438+ results . testEvents (). assertThatEvents ().haveExactly ( 1 ,
439+ finishedWithFailure ( instanceOf ( ExtensionConfigurationException .class ),
440+ message ( it -> it . contains ( "could not be constructed because of an exception" ))) );
438441 }
439442
440443 }
@@ -491,6 +494,7 @@ public Locale get() {
491494 static class ReturnsNullLocaleProvider implements LocaleProvider {
492495
493496 @ Override
497+ @ SuppressWarnings ("NullAway" )
494498 public Locale get () {
495499 return null ;
496500 }
0 commit comments