Nurseyit Tursunkulov
Nurseyit Tursunkulov

Reputation: 9380

How to create object from Data class? Kotlin

I have a

data class A(){ fun c(){} } .

I need to create a fake implementation of it for testing, but it says that class must be open. open modifier is incompatible with data class. Any ways to do it?

Upvotes: 0

Views: 152

Answers (1)

Rafa
Rafa

Reputation: 3339

To mock final classes update mockito

testCompile 'org.mockito:mockito-core:2.8.9' and then add a folder in your resources folder called mockito-extensions that includes a text file called org.mockito.plugins.MockMaker. Inside there just add

mock-maker-inline

That should solve your problem

Upvotes: 1

Related Questions