lundi 26 janvier 2015

Any reasons NOT to write self testing Python code?


Whilst writing tests I was giving considerable thought to the question of how to ensure I have tests for every class in my application.


It occurred to me that maybe I should just put the test code into the classes, thereby making it obvious that each class has a test and vice versa.


I found that this is called "self testing code" http://ift.tt/1uTPOvW


So of course in software development there's always going to be plenty of people who say THAT'S A TERRIBLE WAY TO PROGRAM, YOU CAN'T DO THAT! I'm interested in hearing what the naysayers have to say about writing self testing classes in Python. What are the reasons its a bad idea?


thanks!



class MyOperation():

def some_useful_function(self):
# do some useful function

def some_other_function(self):
# do some other function

class Test_MyOperation():

def test_something(self):
# some test code
assert(True)

def test_something_else(self):
# some more test code
assert(True)




Aucun commentaire:

Enregistrer un commentaire