Reputation: 1
Write a Junit test case for a protected void method without arguments, which does nothing.
protected void init() {
i=10;
j=20;
}
Now, I want to write a Junit for init()
method which does nothing apart from initialization. Any help is appreciated. Thanks in advance.
Upvotes: 0
Views: 204
Reputation: 19545
If you want to check that the fields are set after the initialization you do exactly that.
@Test
public void fieldAreInitialized()
{
YourClass x = new YourClass();
x.methodWhichCallsInit();
Assert.assertEquals(10, x.getI());
Assert.assertEquals(20, x.getJ());
}
Upvotes: 2