mocking in Scala
Feb. 12th, 2014 01:27 pm![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Now, say, I have a class
and I want to run my tests without having to talk to any database.
Here's what I write in my unittest:
I do override stuff, but actually all I need to get rid of actual db is this:
That's it.
class ParseBCBSofTX(val be: BrowsingExec, pat_ins: Patient_ins)
and I want to run my tests without having to talk to any database.
Here's what I write in my unittest:
lazy val mockParser = new ParseBCBSofTX(null, pi) with MockDB { thisParser => /*overriding some methods*/
I do override stuff, but actually all I need to get rid of actual db is this:
with MockDB
That's it.