Skip to content

Instantly share code, notes, and snippets.

@msbaek
Created January 22, 2016 08:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save msbaek/f2e58256b485e5dc5571 to your computer and use it in GitHub Desktop.
Save msbaek/f2e58256b485e5dc5571 to your computer and use it in GitHub Desktop.
parameter, result의 array를 가지고 자동으로 테스트 수행
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import java.util.Arrays;
import java.util.Collection;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
@RunWith(Parameterized.class)
public class ExceptionResolverParameterizedTest {
private ExceptionResolver underTest = new ExceptionResolver();
private String someString;
private String expectedResult;
public ExceptionResolverParameterizedTest(String someString, String expectedResult) {
this.someString = someString;
this.expectedResult = expectedResult;
}
@Parameters
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][] { { "http://www.daum.net?q=q&f=f", "http://www.daum.net?q=q&f=f" },
{ "my test.asp?name=ståle&car=saab", "my%20test.asp?name=st%C3%A5le&car=saab" } });
}
@Test
public void testEncode() {
String actualResult = underTest.encode(someString);
assertThat(actualResult, is(expectedResult));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment