• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package junitparams;
2 
3 import junitparams.internal.parameters.ParametersReader;
4 import org.junit.Test;
5 import org.junit.runner.JUnitCore;
6 import org.junit.runner.Result;
7 import org.junit.runner.RunWith;
8 import org.junit.runner.notification.Failure;
9 
10 import static org.junit.Assert.assertEquals;
11 
12 import static java.lang.String.format;
13 
14 public class MultipleParameterProvidersTest {
15 
16     @RunWith(JUnitParamsRunner.class)
17     private class CantInitializeWithValueAndMethodProvider {
extraProvider()18         private Object[] extraProvider() {
19             return new Object[][]{
20                 {"test", "test"},
21             };
22         }
23 
24         @Parameters(value = {"test, test"}, method = "extraProvider")
25         @Test
testWithValueAndMethodProviders(String input, String output)26         public void testWithValueAndMethodProviders(String input, String output) {
27             assertEquals(input, output);
28         }
29     }
30 
31     @Test
testWithValueAndMethodProvidersThrowsIllegalStateException()32     public void testWithValueAndMethodProvidersThrowsIllegalStateException() {
33         Result testResult = JUnitCore.runClasses(CantInitializeWithValueAndMethodProvider.class);
34         assertEquals(1, testResult.getFailureCount());
35 
36         Failure testFailure = testResult.getFailures().iterator().next();
37         assertEquals(IllegalStateException.class, testFailure.getException().getClass());
38         assertEquals(format(ParametersReader.ILLEGAL_STATE_EXCEPTION_MESSAGE, "testWithValueAndMethodProviders"),
39                      testFailure.getMessage());
40     }
41 }
42