I have the following public void method:
public void setValidFrom (java.util.Date validFrom) {
_validFrom = validFrom;
}
I try to run a JUnit test for which I need to set a Date using the method upon:
@Test
public void testSomething
try {
Object.setValidFrom(validFrom); //Error: validFrom cannot be resolved to a variable
}
How can I set a date here for validFrom
in this test case?
I tried to define a variable in the test case itself but I do not think that is the correct approach. This was my approach:
java.util.Date validFrom = new java.util.Date();
And my JUnit got a NullPointerException
.