The next issue that I saw was that my database method dbHelper:onCreate wasn't called as intended. dbHelper is inherited from SQLiteOpenHelper.
That behaviour was actually correct. The onCreate method is only called when Android needs the database.
Many of the current constants in dbHelper are hardcoded. I need to replace them with strings that I can change in the top of the file.
First TDD Test
The first TDD test checks that I can add a simple entry to the database (containing only one direction) and that I can read it out from the database.
The test intially failed since I've stubbed the addEntry method. After fixing that, I got an exception when querying the database.
That issue was caused by a typo. I missed to add a white space in the SQLite query.
Once that was fixed, I was able to pass the first Test Driven Development test case. I've updated the Github repo.
The next TDD test cases will cover:
- How to add data to an existing entry
- How to handle queries for non-existing entries
- Ensuring that the database won't add entries in the opposite direction. If "From A, B to C, D" exists, "From C, D to A, B" shouldn't be added.
No comments:
Post a Comment