Search in sources :

Example 1 with ArgumentsProvider

use of org.junit.jupiter.params.provider.ArgumentsProvider in project junit5 by junit-team.

the class ParameterizedTestExtensionTests method argumentsRethrowsOriginalExceptionFromProviderAsUncheckedException.

@Test
void argumentsRethrowsOriginalExceptionFromProviderAsUncheckedException() {
    ArgumentsProvider failingProvider = (context) -> {
        throw new FileNotFoundException("a message");
    };
    FileNotFoundException exception = assertThrows(FileNotFoundException.class, () -> arguments(failingProvider, null));
    assertEquals("a message", exception.getMessage());
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) ParameterizedTestExtension.arguments(org.junit.jupiter.params.ParameterizedTestExtension.arguments) Arrays(java.util.Arrays) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) JUnitException(org.junit.platform.commons.JUnitException) Set(java.util.Set) Lifecycle(org.junit.jupiter.api.TestInstance.Lifecycle) ExtensionContext(org.junit.jupiter.api.extension.ExtensionContext) Arguments(org.junit.jupiter.params.provider.Arguments) FileNotFoundException(java.io.FileNotFoundException) Test(org.junit.jupiter.api.Test) Stream(java.util.stream.Stream) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) TestTemplateInvocationContext(org.junit.jupiter.api.extension.TestTemplateInvocationContext) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Map(java.util.Map) Optional(java.util.Optional) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) ArgumentsProvider(org.junit.jupiter.params.provider.ArgumentsProvider) ArgumentsSource(org.junit.jupiter.params.provider.ArgumentsSource) Method(java.lang.reflect.Method) AnnotatedElement(java.lang.reflect.AnnotatedElement) ArgumentsProvider(org.junit.jupiter.params.provider.ArgumentsProvider) FileNotFoundException(java.io.FileNotFoundException) Test(org.junit.jupiter.api.Test)

Aggregations

FileNotFoundException (java.io.FileNotFoundException)1 AnnotatedElement (java.lang.reflect.AnnotatedElement)1 Method (java.lang.reflect.Method)1 Arrays (java.util.Arrays)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Stream (java.util.stream.Stream)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)1 Assertions.assertFalse (org.junit.jupiter.api.Assertions.assertFalse)1 Assertions.assertThrows (org.junit.jupiter.api.Assertions.assertThrows)1 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)1 Test (org.junit.jupiter.api.Test)1 Lifecycle (org.junit.jupiter.api.TestInstance.Lifecycle)1 ExtensionContext (org.junit.jupiter.api.extension.ExtensionContext)1 TestTemplateInvocationContext (org.junit.jupiter.api.extension.TestTemplateInvocationContext)1 ParameterizedTestExtension.arguments (org.junit.jupiter.params.ParameterizedTestExtension.arguments)1 Arguments (org.junit.jupiter.params.provider.Arguments)1 ArgumentsProvider (org.junit.jupiter.params.provider.ArgumentsProvider)1