This is a curiosity question. A couple of times here at the Monestary, I've come into a thread and worked up a test framework for the various solutions posted. Here are examples:

In a single script, I send multiple tests to each of multiple solutions. Pseudocode:

foreach my $solution ( ... ) { foreach my $test ( ... ) { ok( ... ); } }

The result is that I get multiple lines of output for each solution when the test script is run. The problem is that I'm really only interested in the solution as a whole. Did it pass all tests or not? The solutions are not otherwise related to each other. I'd like to get a report like Test::Harness would give for separate test scripts. I'd like to have something notionally like this:

foreach my $solution ( ... ) { harness "tests for $solution" { foreach my $test ( ... ) { ok( ... ); } } }

Then instead of:

ok 1 - kyle test 1 ok 2 - kyle test 2 ok 3 - elyk test 1 not ok 4 - elyk test 2 # four # lines # of # stuff

...I could get something like this:

kyle...ok elyk...dubious

It would be nice if there were a flag I could set to tell it whether to summarize results or show individual tests. I can think of two ways to get something like what I want, but they're both more pain than I'm willing to endure.

One is to write separate files for each solution. I could put each solution in a heredoc, write them out to a bunch of test files and have Test::Harness actually execute them all individually.

The other is to not execute individual tests as tests. Instead of ok() everywhere, just check the test results manually and call a single pass() or fail() for each solution. If I did this, I'd probably end up writing my_own_ok(), etc. I'd do this so that it would be easy to run it as a full test (without the harness) if I'm interested in the details of one solution.

Is there a better way to do what I'm looking for?


In reply to Can Test::Harness treat sets of tests as files? by kyle

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.