UnitTesting internals... again. rubot: smack mmscili
I am building an app to help me journal my time. It is similar to a blog (eventually may feed a blog). After creating JournalEntry and JournalEntryCollecition. I wanted to persist the collection.
My initial testing thoughts were:
- Serialization is simplest way.
- How to test serialize works?
- Make sure file isn't there.
- Add Entry (should serialize automatically)
- Test for file existence.
This lead to:
- How do I know file name? Don't know
- Should I send it in? or should object publish it?
- Let's base it on a guid (.xml).
- Added guid to JournalEntry.
- Duh. We are serializing the collection into a file, not individual items to each file.
- Add guid to Collection? Wait, let's think again.
- Eureka. Forget all this complicated crap.
Final test:
- Create Collection, add item, kill collection. Create new collection, hydrate, test item.
There was no need to test internals. For now, I assume the collection always has all the entries.
Only issue: I am actually testing the save and load at the same time. Hmm.