简体   繁体   中英

How to mock instantiating a new object with any not null parameter with JMockit

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!

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM