On Feb 16, 10:30 pm, Ben Finney <ben+pyt...@benfinney.id.au> wrote: > Lacrima <lacrima.ma...@gmail.com> writes: > > And I have already refused to write totally isolated tests, because it > > looks like a great waste of time. > > It only looks like that until you chase your tail in a long, fruitless > debugging session because (you later realise) the behaviour of one test > is being affected by another. Test isolation is essential to ensure that > your tests are doing what you think they're doing. > > -- > \ “A ‘No’ uttered from deepest conviction is better and greater | > `\ than a ‘Yes’ merely uttered to please, or what is worse, to | > _o__) avoid trouble.” —Mohandas K. Gandhi | > Ben Finney
Hi! Right, isolation is essential. But I can't decide to which extent I should propagate isolation. For example, in "Python Testing: Beginner's Guide" by Daniel Arbuckle, author suggests that if you do unittesting you should isolate the smallest units of code from each other. For example, if you have a class: Class SomeClass(object): def method1(self): return 5 def method2(self): return self.method1 + 10 According to the book, if you want to test method2, you should isolate it from method1 and class instance('self'). Other books are not so strict... And what should I follow as newbie? Currently, I don't create mocks of units if they are within the same class with the unit under test. If that is not right approach, please, explain what are best practices... I am just learning TDD.. with regards, Maxim -- http://mail.python.org/mailman/listinfo/python-list