More reasons to split the big test file into smaller test files:

Suppose 3 months pass and then some test fails. If the tests are split into multiple test files, it's easier to assess the failure. If you organize tests so that they are run in an order that reflects dependencies, you'll more quickly understand what's wrong. Say the first test is to see if authentication is working and tests that follow assume authentications. You know that if something is wrong with the authentication process, then all the tests that follow (that don't test authentication but that need it) will also fail.

Splitting the tests into multiple test files increases the likelihood that (3 months from now) you'll understand what the test verifies with only a peek at the test code.

Splitting test tests into multiple test files allows you to reuse test logic - you can build a test library. A test that verifies that invalid authentication does not allow access has a lot in common with a test that verifies that valid authentication does allow access.

Splitting tests into multiple files allows you to reduce conditional logic in tests. Suppose you have 3 different user types and you want to verify that they can do what they should and that they can't do what they shouldn't. You might be tempted to write a for loop that loops over the users and in that loop you put logic that will either run a test or not run a test. A better solution is to test each individually.

Gerard Meszaros wrote a wonderful book "xUnit Test Patterns - refactoring test code." Only after my test suite was a year or two old, did I find and appreciate that book.


In reply to Re: Sharing configuration information among test files by jimX11
in thread Sharing configuration information among test files by talexb

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.