Re: Grouping tests
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > Apache Server configuration support > Apache Mod-Python > Re: Grouping tests




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Re: Grouping tests  
Jim Gallacher


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-31-06 05:03 AM

This isn't too different from what I have in mind, except that my main
testrunner.py script uses introspection to discover the tests. Adding a
new test set won't require editing testrunner at all. The testrunner
will also filter the tests according to certain criteria, such as mpm or
os, so that tests for a specific platform are automatically selected.

More later.

Jim


Mike Looijmans wrote:
> What I have been doing in a totally unrelated Python project is to
> create test groups simply by putting them into separate modules. The
> main test module test.py looks like this:
>
> ## (test.py)
> import unittest
> from test_something import *
> from test_someother import *
> from test_yetmore import *
> if __name__ == '__main__':
>     unittest.main(module=__import__(__name__))
> ##
>
> This works because unittest takes all 'things' that start with 'test' in
> the provided module and runs them. So anything we bring into our
> namespace gets run. This also makes it possible to import tests from
> other projects, and share these tests between projects.
> The other test_ modules look much alike:
>
> ## (test_something.py)
> import unittest
> import test_peer
> class test04MultiPeerSystem(test_peer.BaseTestRealThing):
>     def test03DiscoveryC08B20(self):
>         "Multiple clients w/ discovery:  8 peers, 20 blocks each"
>         self.runDiscoveryTest(nclients = 8, nblocks=20)
> if __name__ == '__main__':
>     unittest.main(module=__import__(__name__))
> ##
>
> This makes it very easy to handle test subsets, and run single test
> suites. Just run
>
> $python test.py
>
> to run ALL the tests. To run just a single set, run
>
> $python test_something.py
>
> And to run a single test, either of these will do:
>
> $python test_something.py test04MultiPeerSystem
> $python test.py test04MultiPeerSystem
>
> The real power shows when you want to run 4 or 5 test sets, and/or only
> parts of some test sets. Just create a new "main" test unit that imports
> the desired ones, and you're set:
>
> ## (test_few.py)
> import unittest
> from test_something import *
> from test_someother import TestOnlyThis
> if __name__ == '__main__':
>     unittest.main(module=__import__(__name__))
> ##
>
> Because some tests take very long to run (in my vocabulary, "long" means
> more than a second), this saves me a lot of time when working on a part
> of a big project, where I don't need to run all tests all the time.
>
> --
> Mike Looijmans
> Philips Natlab / Topic Automation
>
>
> Jim Gallacher wrote:
> ...
> 
>
>
>







[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 01:16 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register