Loading ...
Sorry, an error occurred while loading the content.

Re: [extremeperl] unit tester

Expand Messages
  • Rob Nagler
    ... I m not a big fan of Mock objects. I only use them when it s absolutely necessary. I like end-to-end tests, even our unit tests hit the database. ... I
    Message 1 of 33 , Aug 29, 2005
    • 0 Attachment
      Rob Kinyon writes:
      > Please explain more about what you mean "weak on the deviance side". I
      > tend to test my failure cases using mocked objects and subroutines,
      > which means the tests are positive tests, not negative ones.

      I'm not a big fan of Mock objects. I only use them when it's
      absolutely necessary. I like end-to-end tests, even our unit tests
      hit the database.

      > As for the repetitive nature ... I look at it as the difference
      > between ASM and Perl. Test::* is ASM, but ASM is very simple to prove
      > correctness for.

      I assume you mean Assembler by ASM. I hypothesize the shorter the
      theory, the easier the proof.

      > The last thing I want is a bug in my testsuite
      > horking up my results. The more complicated the testing
      > infrastructure, the more likely bugs will appear.

      The shorter the tests, the fewer the number of bugs. By encapsulating
      repetition through declarative programming, we not only can prove
      certain aspects of the test structure automatically. Let's go back to
      the EMA example:

      use strict;
      use Test::More tests => 2;
      use Test::Exception;
      BEGIN {
      use_ok('EMA');
      }
      dies_ok {EMA->new(-2)};

      Suppose I do this:

      use strict;
      use Test::More tests => 2;
      use Test::Exception;
      BEGIN {
      use_ok('SMA');
      }
      dies_ok {EMA->new(-2)};

      And suppose I had copied the SMA test to make the EMA test, because
      it's so verbose that I find copy-and-paste faster. The above test
      will pass, incorrectly. However, let's look at what Bivio::Test does:

      use strict;
      use Bivio::Test;
      Bivio::Test->new('SMA')->unit([
      EMA => [
      new => [
      -2 => Bivio::DieCode->DIE,
      ],
      ],
      ]);

      This test will fail. The SMA import will pass, but the create_object
      will fail (SMA->new('EMA') does not return a valid object, and in
      fact, dies). The infrastructure does not pass the case silently.
      Instead, it explains to me why the case failed, that is, because there
      was no valid object to test.

      The danger of simple -- as in repetitive -- is that there are more
      components for the human eye to validate. By programming
      declaratively, I create complex infrastructure for repetitive tasks,
      and use them repetitively. If testing were a "one off", I wouldn't do
      this. However, the Rule of Three applies in spades when it comes to
      testing, and Perl gives you some extremely powerful tools to eliminate
      repetition.

      Rob
    • Dave Cross
      ... You didn t get a reply to this. I hope this isn t too late to be useful. prove is a command line test runner. It s included with recent versions of
      Message 33 of 33 , Sep 14, 2005
      • 0 Attachment
        Terrence Brannon wrote:
        > Adam Sroka <adam.s@...> writes:
        >
        >
        >>I just use Test::More and prove.
        >
        >
        > what is prove? I could not find it in the main Test::More docs:
        >
        > http://search.cpan.org/~mschwern/Test-Simple-0.60/lib/Test/More.pm

        You didn't get a reply to this. I hope this isn't too late to be useful.

        prove is a command line test runner. It's included with recent versions
        of Test::Harness.

        http://search.cpan.org/dist/Test-Harness/

        Dave...
      Your message has been successfully submitted and would be delivered to recipients shortly.