Discussion:
Tagging tests
Daniel Perrett
2012-04-24 18:09:19 UTC
Permalink
Is there any way to 'tag' tests in Perl?

What I mean is, that ideally, if you tagged all your tests according
to the functionality they depended on, you could use the tags to more
easily work out what was going wrong.

# Looks like you failed 21 tests of 75.
# Failures by tag:
# syntax: 0/50
# lwp: 21/25
# http: 21/21
# search: 20/20
# unicode: 5/8

This report is for some hypothetical module which imports some syntax
and allows the user to run some searches over the web via an LWP
object.

Here, we can see at a glance that there is nothing wrong with the
syntactic code, and the code which requires LWP itself is probably
fine because the problem only comes when the user tries to make http
requests.

It looks likely that even though all the search tests fail, they are
failing because there is no working connection, as tested by the first
http request. Although five of the unicode tests are failing, three
aren't (throwing unicode characters at the syntax).

Assuming there isn't any way to 'tag' tests, like this, should there
be? The problems I can see are:

- How to make it easy to do syntactially, avoiding lots of repetition
- Whether this requires a complete rewrite of the assumptions of the
core test handling modules
- The effort involved for test authors in tagging tests in this detail
- Some test failures happen something unexpected went wrong, and
tagging is only useful if we know what categories are useful.
- It could encourage authors to be lazy

But the advantages are

- If there are common problems (computer can't access the net, unicode
handling is dodgy), this makes it more straightforward to diagnose
than reading through logs of very long test scripts with lots of
failure diagnostics
- Might be useful for coverage checking (you could write something
asking if you have a test which has a particular combination of tags)
- You can write more clever algorithms to try to pinpoint where the
problem is (e.g. which combinations of tags always fail)
- Makes TDD easier because you can write lots of tests which will fail
(and you know you can ignore because they depend on code that isn't
written yet), and you can still focus on the features you're writing
right now.

(I guess one answer could be 'write them in separate test scripts' but
what I want is tags (many-to-many) rather than categories
(many-to-one), and more files is a bit cumbersome.)

Daniel
Greg Sabino Mullane
2012-04-25 18:44:59 UTC
Permalink
Post by Daniel Perrett
Is there any way to 'tag' tests in Perl?
Not that I can think of, in the way that you want.
Post by Daniel Perrett
It looks likely that even though all the search tests fail, they are
failing because there is no working connection, as tested by the first
http request. Although five of the unicode tests are failing, three
aren't (throwing unicode characters at the syntax).
Seems to me the easiest way to handle that is to have simple tests
at the start of your chain that BAIL OUT if they see a major problem.
While the unicode wouldn't be in that solution, I can't see how the
complexity of adding tags would prevent a user from having to manually
look at the failing tests anyway.
Post by Daniel Perrett
(I guess one answer could be 'write them in separate test scripts' but
what I want is tags (many-to-many) rather than categories
(many-to-one), and more files is a bit cumbersome.)
Perhaps you can give a more convincing/real-world test case where
this would be needed? I would think that a single early test catching
many known major failures would be the way to go. If there was something,
such as unicode, which warranted tags, I'm not sure why it wouldn't warrant
it's own group of tests. Tests are the one are where I never worry about
overlap, efficiency, or having too many files. :)
--
Greg Sabino Mullane ***@endpoint.com
End Point Corporation
PGP Key: 0x14964AC8
Lars Dɪᴇᴄᴋᴏᴡ 迪拉斯
2012-05-01 18:17:23 UTC
Permalink
Post by Daniel Perrett
Is there any way to 'tag' tests in Perl?
<http://p3rl.org/Test::Less>
Post by Daniel Perrett
- If there are common problems (computer can't access the net, unicode
handling is dodgy), this makes it more straightforward to diagnose
than reading through logs of very long test scripts with lots of
failure diagnostics
<http://analysis.cpantesters.org/>
Daniel Perrett
2012-05-01 18:57:56 UTC
Permalink
Thanks, I'll look into both!

Daniel
Post by Lars Dɪᴇᴄᴋᴏᴡ 迪拉斯
Post by Daniel Perrett
Is there any way to 'tag' tests in Perl?
<http://p3rl.org/Test::Less>
Post by Daniel Perrett
- If there are common problems (computer can't access the net, unicode
handling is dodgy), this makes it more straightforward to diagnose
than reading through logs of very long test scripts with lots of
failure diagnostics
<http://analysis.cpantesters.org/>
Loading...