I've been tinkering today. I'm working in Python/Jython on an automated test harness. Typically, I'm standing on the shoulders of giants : the developers who have given me an API with which to test their Java app using a bit of Jemmy magic. I hope to have (relatively) large shoulders for my testing colleagues to stand on, and that means hiding / abstracting the API that I've been given even further. It's going well, but it's not quite there yet. Today I needed to write a very specific test, and there were two approaches that I could take. One was to extend an existing class which takes scripts as Python lists, to be able to do a drag and drop action. The other was to create a new class to allow custom/bespoke tests to be written without resorting to too much reproduction of boilerplate code.
Eventually I got something working. Ironed out some niggles, and was quite pleased. It would have been easy to leave it at that. It was certainly good enough. It seemed a bit clumsy though. There was still a lot of work in subclassing and calling my bespoke test (It's called 'custom', but I already know it'll be called 'bespoke in about 4 hours if I ever get some sleep). I needed to figure out a way of getting boilerplate out of a function that created an instance of a subclass and into the parent class, where it could be forgotten about for all eternity by people writing the tests.
A solution (which may itself be refactored), was to pass a parameter (called 'parameters', containing a Python dictionary, which can be accessed by key, which makes it human readable) into the parent class' constructor, the constructor calls some functions which can be overridden by the subclass. The parent class has a function that calls the test body and records results, and the test body is overridden in the subclass to do the stuff that the test writer wants to do.
It means that the test writer subclassing the bespoke test class now doesn't need give a monkey's chuff about the boilerplate code. He (Sadly we are all 'He' in the lab at the moment) just writes some simple steps and can assume that the environment for executing those steps is initiated and torn down automatically.
Wednesday, 25 March 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment