[qmtest] Upgrading tests
Vladimir Prus
ghost at cs.msu.su
Wed Dec 24 09:24:46 UTC 2003
Mark Mitchell wrote:
> > Is something like this available somewhere, or planned?
>
> No, there's nothing like that available, but it is a good idea.
>
> It should not be too hard to write a method that iterates over each test
> in a database, and rewrites the test.
Okay, I've implemented this, and successfully processed around 70 tests --
which would be pain to upgrade manually.
The way upgrading works with my implementation is quite simple. If a user
wants to change some test class, say "History", he first writes new class
"History2". The new class, besides other methods, should have 'Upgrade'
method. He tests the new class on a couple of tests -- which must be manually
upgraded, and they runs
qmtest ... upgrade-tdb
--from some_module.History --to some_module.History2
The upgrade logic is
1. Old test is loaded
2. Instance of new test class is created
3. Method 'Upgrade' on the new instance is called with the old class instance
4. The test is saved.
I'd be happy to send the patch, if there's interest, but there are two things
I don't like and would prefer to cleanup -- and that requires some
discussion.
First, problem is that database can't save tests, only instances of
TestDescriptor. I'm thinking that either database should be able to save
tests, too, or there should be a method in Test which return TestDescriptor.
The biggest problem is that it's hard to create default-initialized instance
of new test class. I can pass empty mapping for arguments, but
Runnable.__init__ expects 'extra' keyword arguments. I can work around this,
too, by passing what Runnable expects, but this starts to be rather messy.
E.g., if Runnable is changes to require another extra keyword argument, my
code will break. Is there some way I can cleanly create default-initialized
test instance?
- Volodya
More information about the qmtest
mailing list