You could use a parameterized test. import static org.junit.Assert.assertEquals; import java.util.Arrays; import java.util.Collection; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; @RunWith(Parameterized.class) public class MyParameterizedClassTest { private string promptNameOrg; public MyParameterizedClassTest(string testParameter, string expectedParameter) { this.promptNameOrg = testParameter; this.expected = expectedParameter; } // creates the test data @Parameters public static Collection<Object[]> data() { Object[][] data = new Object[][] { { "20129142\\1234", "1234" }, { "80808080\\159;20129142\\1234", "1234" } }; return Arrays.asList(data); } @Test public void extractSimplePromptNameFindsLastPartOfString() { String simplePromptName = extractSimplePromptName(this.promptNameOrg); Assert.assertEquals(this.expected, simplePromptName); } // extractSimplePromptName omitted } There can only be one @Test in such a class, though. More info can be found here: http://www.vogella.com/tutorials/JUnit/article.html#junitadvanced_parameterizedtests