I'm working on a class that should manipulate files.
Its interface has a Open(string filename)
method, and various other methods to retrieve and manipulate the contents.
Is it ok to call the open method before calling the method I'm trying to test?
On one side, this documents the fact that the open method should be called before any other method.
On the other hand, I'm worried about the effectiveness of those tests as, if the Open
method stops working, all tests would fail without actually reporting a failure of the method they should test.
Things I considered:
Using reflection while testing to put the object into a known "workable" state, without calling the open method (complex and hard to maintain)
Using a static construction method that creates the object and then opens it, returning the working object (but there should also be an option to have the object in a "closed" state, plus this doesn't avoid calling the open method, it just hides it)