Skip to main content
6 events
when toggle format what by license comment
Jul 25, 2016 at 23:06 vote accept Ayb4btu
Jul 25, 2016 at 22:55 comment added forsvarir @Ayb4btu As I said, it's style dependant. As long as the test is repeatable and either always works or always fails, there's nothing wrong with using files for testing. Some people believe you should mock everything / never interact with external resources. However if you were going down that route, you would probably be mocking out the CsvReader itself, which you're not doing. I would put the choice down to how much effort is involved in each approach against how fast the tests will run. However, if this is in shared source, the decision often comes down to what works for the team.
Jul 25, 2016 at 22:50 comment added Ayb4btu Ok, so I then can pass the TextReaderor path into the constructor instead. I assume I should just pick one or the other instead of having a constructor for both? I'm thinking the path is the more suitable approach, but is testing using external files a common practice, or is this frowned upon?
Jul 25, 2016 at 22:38 comment added forsvarir @Ayb4btu depends a bit on your usage, but since I assume LocationData and CountData aren't valid until after you've read from the file, I would probably make the read method private and call it directly from the class constructor.
Jul 25, 2016 at 22:34 comment added Ayb4btu These approaches would just get rid of the constructor as well? Initially I had the constructor calling ReadSporeCountData, but I'm guessing calling a separate method is better?
Jul 25, 2016 at 22:05 history answered forsvarir CC BY-SA 3.0