Posted By:
Mike_Oberegger
Posted On:
Tuesday, May 15, 2007 10:57 AM
I apologize if this was posted before. I did a search and everything, and it doesn't seem like the question was posted. I was wondering if there was a way to send parameters to a test. For example, instead of doing this: public class TestMyMath { @Test public final void testAdd() { assertEquals("Bad add.", 12, MyMath.add(6, 6)); } I could do this: public class TestMyMath { @Test public final void testAdd(int a, int b, int exp) { assertEquals("Bad add.", exp, MyMath.add(a, b)); } and I wouldn't have to hardcode any test cases. This way, I could reuse the same test,
More>>
I apologize if this was posted before. I did a search and everything, and it doesn't seem like the question was posted.
I was wondering if there was a way to send parameters to a test. For example, instead of doing this:
public class TestMyMath {
@Test
public final void testAdd() {
assertEquals("Bad add.", 12, MyMath.add(6, 6));
}
I could do this:
public class TestMyMath {
@Test
public final void testAdd(int a, int b, int exp) {
assertEquals("Bad add.", exp, MyMath.add(a, b));
}
and I wouldn't have to hardcode any test cases. This way, I could reuse the same test, but with different values. Any help would be appreciated.
Thanks.
<<Less