While Constructing parameterized test cases in JUnit4,we are using Super keyword.I didn't understand what is the use of Super keyword here.What happens if this keyword is not used here? I am attaching a JUnit parameterized test case for string reverse as an example.
package BasicTesting;
import static org.junit.Assert.*;
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 Corrected_String_Test {
public Corrected_String_Test(String input, String expected) {
super();
this.input = input;
this.expected = expected;
}
Corrected_StringRev ob=new Corrected_StringRev();
private String input;
private String expected;
@Parameters
public static Collection<String[]> testConditions() {
String expected[][]= {{"acd","dca"},{"12d","d21"},{"j h","h j"},{" hg"," gh"},,{"&*","*&"}};
return Arrays.asList(expected);
}
@Test
public void RevStringtest() {
assertEquals(expected,ob.reverseString(input));
}
}
Please help me to find answer.Thanks in adavance!
super()will call the default, no args constructor of the super class. In your case, there is no superclass (besidesObject), so there's no effect of having it here.