TestOOB - Finally learning again
I finally found some challenge again. I am learning again, I am reading source code that really is nicely written and well structured. I have the feeling that got somehow lost in my PHP days. The TestOOB source makes use of various design patterns, where it makes sense and is thread-safe. Somehow it seems that the language Python attracts the people that really understand those concepts and the level of programming is much higher than in most PHP projects. That is a challenge and it will take me a while to make it up to understand it all and to feel comfortable at this level, I am very excited about the upcoming time. That is the salt in the soup of a programmers life. Yeah!
After writing the post “What I want from a (unit)test module” I got a nice mail from Ori Peleg, the author of TestOOB, where he told me that he has added some things as ideas in his Trac[ker]. Wow, that sounded cool. The option –repeat is even already implemented, I am impressed. That’s what is so great about open source, things just happen and get done. And that also got me rollin’. I am now looking into the source of testoob and of course I am using it for my testing. I even started to add some little feature and the process of generating ideas is rollin’ too :-).
TestOOB is no replacement for the unittest module, it just fixes what unittest lacks to provide. After I had read this article I wanted to implement the features mentioned in the paragraph above into unittest. The article said it would be a piece of cake I felt I was able to do it. But it was not really that easy. I added the --repeat feature (in a dirty way), but to make it a command line argument I had no chance than modifying the existing source, simply extending was not possible!
So TestOOB came along when Ori mailed me and I saw that there was movement as opposed to unittest, which seems to be “complete” and solid.
For a quick overview of what TestOOB provides additionally, it’s enough to list the command line parameters that are available additionally to those unittest provides:
--immediate, -i Immediate feedback about exceptions --vassert Verbalize the assert calls --list, -l List the test classes and methods found --regex=REGEX Filtering regular expression --glob=PATTERN Filtering glob pattern --xml=FILE output results in XML --html=FILE output results in HTML --color Color output --interval=SECONDS Add interval between tests --timeout=SECONDS Fail test if passes timeout --stop-on-fail Stop tests on first failure --debug Run pdb on tests that fail on Error --threads=NUM_THREADS Run in a threadpool --processes=NUM_PROCESSES Run in multiple processes --repeat=NUM_TIMES Repeat each test
I personally use –vassert, –color and –list quite often.
Got your lips wet, you want to use it?
- Download and install TestOOB, from here,
- call
testoob.main()instead ofunittest.main(),
when you become more familiar with it, and decide to stick to testoob you will surely put the import at the beginning of the file as you normally doif __name__ == '__main__':unittest.main()import testoob testoob.main() - type
--helpbehind your file in the command line, and you can see you got all the power of TestOOB at your finger tips.
The following paragraph just came up without intention, it used to be the second paragraph, but somehow it doesn’t fit into the entire blog-entry (I still got some to learn to start calling this an article :-)) at all, so I just put it here, at the end. It is common knowledge anyway …
Actually it’s easy to find reasonable explainations for why Python seems to attract a more advanced audience. PHP is just a quick-to-pick-up language and it attracts a lot of people, also those with little or no programming know-how. That of course is also one goal of PHP, which I think is a cool thing!
Python might seem very easy to pick up too, and it is. At least in the beginning. But once you get deeper into programming, which mostly involves reading/modifying/using other people’s code, it starts to become more ambitious. You find yourself learning OOP, SQL and various other concepts of computer science. But it’s for good, you become more productive.
Phillip J. Eby said,
November 7, 2005 at 6:35 pm
I’m not sure why you feel code modification would be necessary. To add a –repeat option, you’d subclass unittest.TestProgram and override the ‘parseArgs()’ and ‘runTests()’ methods.
shpilman said,
April 4, 2006 at 6:59 pm
Jeg hilser til klovnen. Jeg liker klovner veldig godt! Jeg har vört põ sirkus og sett klovner.