1. Computing

Say What? Making Sense of Common Terms in Test-Driven Development

Test Unit Terminology

By

There's a lot of jargon thrown around when you talk about Test Driven Development. Here's a list of common terms used in TDD (and specifically in Test::Unit) that you should know.

  • Test Method - A method that tests a specific feature. Each of the methods starting with test are the test methods. Test methods manipulate the objects to be tested and run a number of assertions on them, which will determine if the test is pass or fail. More often referred to as just a "test."

  • Assertion - A method that will pass or fail the test method if certain conditions are met. The most basic assertion is the familiar assert_equal. If the two objects passed to assert_equal are not equal, then the assertion will fail, which causes the test to fail. No further assertions are run in a test if one of the assertions fails, however all assertions in a test must pass in order for the test to pass.

  • Test Fixture - Any objects created before and destroyed after any test in a test suite. These objects are created using the setup method, and destroyed using the teardown method. The setup and teardown methods are called around each test method, so test methods don't need to worry about any changes they've made to the fixture objects.

  • Test Case - A collection of test methods and an optional test fixture. Test cases are classes that have inherited from Test::Unit::TestCase. Any methods in them that begin with test_ are considered to be test methods, and will run when the test case is run.

  • Test Suite - A collection of test cases. A test suite gathers the test cases, runs the test methods, then gathers and formats the results and displays them to the user. If you're simply running test cases, you won't ever have to see test suites. However, gathering your test cases into test suites can help give you a better UI and provides more opportunity to run tests often.

  • Run - A test run is the running of a test case or test suite. Used as both a noun and verb, you could say "run the tests" or "there were no more errors when I gave it another run."

  • Test Result - The aggregated results of all the tests. Depending on your user interface, this can be very different. Tests may be displayed as only a single dot when they pass, or all of them could be listed along side their pass or fail status. It's recommended that you use a user interface with color capability so passes and failures really stand out.

  • Red and green - Failing tests are red, passing tests are green. You can say a test "is red" or has "gone red." Put simply, it's your job to make all the tests "go green." Many user interfaces will display tests in red and green to help you isolate failing tests quickly. Other interfaces (such as HTML interfaces) may use other graphics, backgrounds and methods to highlight tests other than simply red and green colors.

  1. About.com
  2. Computing
  3. Ruby
  4. Advanced Ruby
  5. Test-Driven Development
  6. Say What? Making Sense of Common Terms in Test-Driven Development

©2014 About.com. All rights reserved.