Is there a JUnit equivalent to NUnit's testcase attribute?
Posted
by
Steph
on Stack Overflow
See other posts from Stack Overflow
or by Steph
Published on 2010-12-29T12:35:59Z
Indexed on
2011/02/02
7:25 UTC
Read the original article
Hit count: 224
I've googled for JUnit test case, and it comes up with something that looks a lot more complicated to implement - where you have to create a new class that extends test case which you then call:
public class MathTest extends TestCase {
protected double fValue1;
protected double fValue2;
protected void setUp() {
fValue1= 2.0;
fValue2= 3.0;
}
}
public void testAdd() {
double result= fValue1 + fValue2;
assertTrue(result == 5.0);
}
but what I want is something really simple, like the NUnit test cases
[TestCase(1,2)]
[TestCase(3,4)]
public void testAdd(int fValue1, int fValue2)
{
double result= fValue1 + fValue2;
assertIsTrue(result == 5.0);
}
Is there any way to do this in JUnit?
© Stack Overflow or respective owner