Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
In a subthread of Neither system testing nor user acceptance testing is the repeat of unit testing (OT), a very lively discussion has been taking place about testing and when unit-tests can be black-box, what's white-box, and various other related topics. I have been getting the sense that my usages of certain terms ("white-box" and "interface", to name a couple) are different from the rest of the world's. While this isn't news to me, I was a little surprised at the ... vigor that was expressed in the conversation.

In the interests of harmony between myself and others, I'm going to elaborate on how I view certain fundamental terms. In all cases, these are my personal views and opinions. As I have done many times in the past, I am more than willing to change my views on any and all of the following items if presented with a compelling argument.

  • CodeSmell

    A situation in your project that, on its face, will cause issues at some point. CodeSmells are derived the accumulated experience of the developer community's failed projects. Not all CodeSmells are necessarily bad, but any CodeSmell that is not changed should be documented as to why this CodeSmell is acceptable in this instance. Otherwise, the maintainer (which will be you in 6 months) will wonder why this CodeSmell was not addressed.

  • Corner-case

    This is a situation where a generalized rule fails on certain specific inputs or input-ranges. For example, division is a generalized rule that has a corner-case when the divisor is 0.

    My opinion is that only reality contains corner-cases. If your code has a corner-case that isn't in the spec, you have code that isn't necessary to meet the spec. (Or, more commonly, you have a crappy spec, but that just means you need to improve the spec.)

  • Specification (aka spec)

    This is where the real-world situation(s) that the code in question should handle are described. This includes the various situations that might arise, the algorithms that need to be handled, and what the code can assume about the world. This also includes any performance requirements/constraints, portability requirements/constraints, the framework that will surround this code (exceptions or not, etc), and anything else from a technical nature. Things that are not specified should be labelled as "implementation-dependent".

    Leap-years and leap-seconds are part of the spec for a date-handling module. Performance requirements like "This must run in under 1 second" are part of the spec.

    In legacy code, the interface may be the implementation, but that does not mean that one is necessarily white-box testing.

  • Interface

    The interface is how anything outside the piece of code in question will deal with that piece of code. This is the list of functions/methods/variables/whatever that the user of this code will have available to them. This list should contain what each of these items does. This includes any assumptions, parameters, and outputs. In the case of an exception-based system, this should include what exceptions are thrown, handled, and any other pieces of code this item uses, so that the user can look there for unhandled exceptions.

    It is very common to have a private interface as well as a public interface. This is where your private methods are tested. While this is very close to white-box testing, it is arguable that the public interface that you are providing uses a second section of code that is not for public consumption.

  • Unit-tests / testsuite

    The unit-tests should verify that a given implentation of the interface, as documented, satisfies the specification, as documented.

  • Implementation

    This is the actual code that does the work. It provides the given interface and satisifies the given specification. It may be optimized, or not.

  • Black-box testing

    These are tests written solely against the interface to validate the implementation against the specification.

  • White-box testing

    These are tests written against the implementation, not the specification. I consider white-box tests to be, in general, a CodeSmell. The only white-boxing I feel to be appropriate is mocking, and if mocking is required, that needs to be justified. (The justification may be as simple as "That's the spec.")

  • Test-Driven Development (aka TDD)

    The practice of writing a test, seeing it fail, writing some code, then seeing the test pass.

    Note: TDD is not necessarily white-box testing, as some have proposed. I only have to point to Pugs for a good example of this.

  • Coverage statistics

    The process of determining which codepoints have been exercised by your testsuite. If there is less than 100% coverage, this is a good place to determine if any of the following are true:

    • Your testsuite is incomplete vis-a-vis the specification
    • You have code that is not required to meet the specification
    • You have code that is untestable

    Either way, this is a CodeSmell that needs to be addressed. (Again, the addressing can be very simple.)


My criteria for good software:
  1. Does it work?
  2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
GrandFather added readmore tags

In reply to (OT) Black- vs. white-box testing by dragonchild

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, 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, 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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others lurking in the Monastery: (2)
    As of 2019-10-21 04:39 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      Notices?