0

I would like to mock the new instance of java.io.File with any not null parameter with JMockit. Here is the code

newInstance("java.io.File", (String) withNotNull(), (String) withNotNull());

But it keeps saying Invalid null value passed as argument 0 and I don't know why because the first parameter is withNotNull()

Please help!

Truong Ha
  • 10,468
  • 11
  • 40
  • 45

1 Answers1

1

The above method call will match File(String parent, String child) constructor in java.io.File API.

From the error, we can understand that the argument parent passed to the constructor is null which it shouldn't be.

That's why it is throwing the error

Keerthivasan
  • 12,760
  • 2
  • 32
  • 53
  • But I passed withNotNull() as the first parameter, so it should be something not null. – Truong Ha Apr 28 '14 at 05:13
  • The expectation is that it should be not `null`. But, the value passed during test is `null`. Can you please add how you get this error? – Keerthivasan Apr 28 '14 at 05:51