Re: [Pyunit-interest] Aid requsted regarding test-first-design
Brought to you by:
purcell
From: Changjune K. <jun...@ha...> - 2001-11-24 01:49:27
|
It will be really helpful if you could tell us the real *thing* (code, maybe?) -- I'm afraid that I can't quite understand your point. ----- Original Message ----- From: "Jesse W" <je...@lo...> To: <pyu...@li...> Sent: Saturday, November 24, 2001 9:51 AM Subject: Re: [Pyunit-interest] Aid requsted regarding test-first-design > Michal- > Thank you for your answer. However, I still have some > difficulties. I will explain below. > Michal Wallace wrote: > > On Thu, 22 Nov 2001, Jesse W wrote: > > > Obviously I should not test _it_ because it is assumed to be > > > working, but I should test my calls to it. Or should I, because the > > > interface between an external library and my program does not have > > > anything to do with the program's _requirements_, does it? But > > > maybe I can because I can choose to create tests supporting that? > > This is a good time to use what they call "Mock Objects". > > > > Make an object (or a function, depending on your needs) that > > handles your FTP stuff. This should wrap the calls to > > ftplib. You can test this manually, or write automated test > > for it but keep them separate, or whatever. This kind of > > thing is usually visible enough that if something goes > > wrong, you know about it. > As I understand what you are saying here, I should make a wrapper > arround ftplib and then test that, although you say maybe I don't > need to because it is simple enough that probblems should be > obvious. But what if I don't know exactly what calls to ftplib I will be > needing? You don't test in advance. You think _in_ tests. If you want to do Z, describe Z as a test in a testing code, then try to make a code that'll pass it. > > Anyway, when you're testing your code, you can substitute > > a mock function for the real thing. > Ah, this is the reason for doing the wrapper thing. But how does > this help me figure out what aspects of my design to test? As I sort- You test all that could possibly break, while trying to implement what you want the system do for you. You don't need to worry about what to test in the first place. Desribe what you want the system do for you in test codes. > of say above, should I test wheather the responses I get from my > wrapper are correct, or should I assume they are correct, and if I Responses from wrappers or mock objects are correct, because you hard-coded correct answers already. > assume this, what should I test if I am doing test-first-design? > I hope I am being at least somewhat clear. > > Thank you for your time, > Jesse Weinstein > June |