All of us know about unit test. But what's a unit?

Discussion in 'Java' started by Bill David, Jun 17, 2008.

  1. Bill David

    Bill David Guest

    A method? A class? A bunch of related classes? A module? An API we
    exposed from a module? ...

    My opinion is all of them are units for different test requirement.
    But my friend doesn't agree. He thinks we should only write unit test
    for a single method of a single class. How do you think?
     
    Bill David, Jun 17, 2008
    #1
    1. Advertising

  2. Bill David

    Tom Anderson Guest

    On Tue, 17 Jun 2008, Bill David wrote:

    > A method? A class? A bunch of related classes? A module? An API we
    > exposed from a module? ...
    >
    > My opinion is all of them are units for different test requirement. But
    > my friend doesn't agree. He thinks we should only write unit test for a
    > single method of a single class. How do you think?


    A unit is the smallest testable part. 'Atom tests' would have been a
    better name :).

    Yes, you can and must test larger assemblies, and it doesn't hurt to make
    this part of your continuous automated testing regime, if the tests run
    fast enough. But the point of unit tests is to verify that all the
    individual components work properly. A larger-scale test might tell you
    that something's broken, but it probably won't tell you what.

    At the other end of the scale, there are 'functional' or 'acceptance'
    tests, which exercise the whole system, or large parts of it. You need to
    have these too, to pick up subtle faults which arise in interactions
    between the smaller parts, but they're the kind of thing you run as part
    of your integration routine, not immediately after every refactoring, as
    you should with unit tests.

    tom

    --
    Miscellaneous Terrorists: Ducks | Bird Flu | Avian flu | Jimbo Wales |
    Backstreet Boys | The Al Queda Network | Tesco -- Uncyclopedia
     
    Tom Anderson, Jun 17, 2008
    #2
    1. Advertising

  3. Bill David

    Arne Vajhøj Guest

    Bill David wrote:
    > A method? A class? A bunch of related classes? A module? An API we
    > exposed from a module? ...
    >
    > My opinion is all of them are units for different test requirement.
    > But my friend doesn't agree. He thinks we should only write unit test
    > for a single method of a single class. How do you think?


    A unit *must* be one or more strongly related classes that
    seen from other developers can be considered a single entity.

    A unit *should preferable* be a single class. But that is
    not always possible.

    Arne
     
    Arne Vajhøj, Jun 18, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Edvard Majakari
    Replies:
    4
    Views:
    696
    Edvard Majakari
    Feb 25, 2005
  2. VvanN
    Replies:
    5
    Views:
    498
    Phlip
    Apr 28, 2006
  3. Bill Mosteller
    Replies:
    0
    Views:
    234
    Bill Mosteller
    Oct 22, 2009
  4. timr
    Replies:
    2
    Views:
    173
  5. Andries

    I know, I know, I don't know

    Andries, Apr 23, 2004, in forum: Perl Misc
    Replies:
    3
    Views:
    259
    Gregory Toomey
    Apr 23, 2004
Loading...

Share This Page