Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: test files - organising

by adamk (Chaplain)
on Feb 11, 2008 at 22:43 UTC ( #667468=note: print w/replies, xml ) Need Help??


in reply to test files - organising

It all depends on the size of the project.

http://svn.ali.as/cpan/trunk/PPI/t/

The PPI test suite is flat (with subdirectories for support and data files and a lib for test classes used by various tests) and yet it is quite a large project.

Then again, it's still only 5k-10k SLOC, and it's still a fairly straight forward structure (it's a plain module).

For truly large applications (using one 200k SLOC web application at work as an example) where the test suites are going to be highly diverse, then it's worth looking at breaking things up a bit.

For this project, the root of /t holds bootstrapping and general tests, with subdirectories to hold various classes of tests.

So the root checks all the modules compile, that they pass certain static analysis checks, that the configuration environment loads ok, and that all the external services identified by the configuration code exist and work.

The root is also where we put all the modules that we want to abort the entire test run on failure.

Then we have things like /t/db which contains all the tests for database sanity, DBI code, tests for the data model classes, etc.

Theres a /t/legacy that holds all the tests we've recovered from previous testing efforts that were later abandoned (this code base is over 10 years old now, and has gone through three generations of coding teams).

The /t/inline directory holds all the tests generated by Test::Inline (which we use to scatter tests for assumptions and what not through the codebase).

A /t/cp holds tests for one everything related to one particularly thorny section of the application.

Then theres /t/www for all the web interface testing, and t/dbmigrate for the tests for the database migration system we invented to deal with incredibly painstaking process of migrating an Oracle database that is too large and complex to be able to recreate from scratch.

And finally a /t/cpan to hold additional regression tests for specific bugs in CPAN modules we depend on. Some of these get submitted back to the original modules and removed later.

We also expect to aquire a /t/selenium directory and a /t/endecca (to test a specific third party search engine).

Within each directory, we still do numeric test names (01_foo.t, 02_bar.t).

Apart from straight forward separation of concerns this structure provides, it also makes life easier because you can use things like prove to test one subset of concerns (prove -r -b /t/db for example) without having to run the entire test suite, which for this application now runs out to 20+ minutes.

The directories also have the side-effect of acting as a basic semantic classification, they add more meaning to the test simply by looking at their file names, without having to read documentation.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://667468]
help
Chatterbox?
[ambrus]: Corion: as for that, I talked with schmorp, and looked a bit more at Prima
[ambrus]: Corion: from the docs, it definitely looks like it would be possible to write an AnyEvent driver for it using Prima::File and Prima::Timer.
[ambrus]: (I haven't found an idle event.)
[ambrus]: However, I also looked at the internals, and found two interesting things:
[marto]: stupid xpath question, I have a xpath copied from the browser, is the * wildcard supposed to work for IDs? e.g. '//*[@id="*"]/ div/div/header/p/a '?
[ambrus]: The main loop for unixish systems is in https://metacpan. org/source/ KARASIK/Prima-1. 49/unix/apc_app.c. It is a hand-rolled select loop, but also always spins at least once every 0.2 seconds for some reason.
[ambrus]: marto: no, not that way. if you just want to test for an existing id attribute, then write *[@id] , or you can match a regexp to the value of that attribute like *[@id=~/something/ ]

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (8)
As of 2016-12-08 10:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (140 votes). Check out past polls.