-
-
Save samsee/dd042d3ea8ec5048c5bf125f076e5a72 to your computer and use it in GitHub Desktop.
JUnit Snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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