Now, I know how the database should be organised. For the implementation, I'll use Test-Driven Development that I described in an earlier blog post for TrafficControl.
The first step is to be able to initiate the database helper at all.
When trying to do that in a local unit test, I wasn't able to initiate the dbHelper class since I couldn't get the context for the app. The reason is probably that I need more resources such as a database that will require an Android environment.
Instead, I was able to use the context in an instrumented unit test. This will be much slower than running locally, since the test needs to be loaded into a real or simulated phone. After some dependency issues for the test APK package that I didn't see for the app, I was finally able to test a simple instrumented test.
In the test, I added a dbHelper that I didn't use. For the local unit test, that step caused a crash.
More information about Android testing can be found here.
The first Test-Driven Development test will be to add columns to the database and check if those columns exist.
No comments:
Post a Comment