1

In the book 'The Art Of Unit Testing' by Roy Eshorove, the unit test is defined as:

automated piece of code invokes the method or class then checks some assumptions about the logical behaviour of that method or class.

fair enough.

But I am not very clear on "automated piece of code."

What is a unit-test to do with automation? Under what conditions you consider a piece of code "automated" so that it can be a requirement of a code to be a unit-test?

tvanfosson
  • 524,688
  • 99
  • 697
  • 795
pencilCake
  • 51,323
  • 85
  • 226
  • 363
  • Don't get hung up on the words.. a unit-test (or a micro-test as some call it) should be self-checking i.e. it should be able to do something, verify the result and report pass/fail without requiring a human. See also http://stackoverflow.com/questions/61400 – Gishu Dec 21 '11 at 10:24

2 Answers2

3

A unit test is an automated piece of code because it can run without any user intervention.

If a user would have to click on a few buttons and fill in some fields for each unit test that runs, it wouldn't be automated and considering the fact that a typical project will have a lot of unit tests it would defeat the whole purpose of having them (especially from a TDD perspective, where you want to run the tests as possible without much work).

Wouter de Kort
  • 39,090
  • 12
  • 84
  • 103
3

Automated in the sense that it can be run automatically by a unit test framework. It contains all the necessary setup to establish the context for the test, run the code under test, and verify that it operates as expected. It doesn't require any manual intervention to ensure that the code can be run.

tvanfosson
  • 524,688
  • 99
  • 697
  • 795