Create a mock to test with junit
Is there a way to test DBFlow without passing a context or a mockcontext (right now is giving us a NPE) to test it with mock data? Maybe passing a db file or something?
We want to create junit tests and and unit tests should not know nothing about context nor other android stuff...
+1
Great idea, that would be really helpful :)
Not currently, you need to get a handle on the database to use it, since it operates using the FlowSQLiteOpenHelper
you can use roboelectric to do that, http://robolectric.org/
@arturonaredo I've successfully mocked both Context and SqlUtils in this example. Will update the sample to 2.2.1 when I get the chance.
Here's the short helper class that makes it possible: SqlUtilsMock
This lets you mock a table for the duration of a test.
Let me know if that works for you or if you have any problems.
@kaeawc do you still have your example ? unfortunately both links you gave are deads.
+1
Does anybody have a backup of this code (SqlUtilsMock)?