Difference between revisions of "Using CDD"

(How to restrict test case execution)
(Getting Started)
Line 5: Line 5:
 
The following will first give a quick overview of the two main features of CDD and then guide you through enabling and using them.
 
The following will first give a quick overview of the two main features of CDD and then guide you through enabling and using them.
  
The two main feature of CDD are test case exectution and test case extraction. The first brings full IDE support for unit testing as known by the xUnit family tools to EiffelStudio. The second adds a novel feature: new test cases are ''extracted'' completely automatically from while the developer programs.
+
The two main feature of CDD are ''test case exectution'' and ''test case extraction''.  
  
 +
== Test Case Execution ==
  
CDD adds two new tool windows, named ''''Testing'''' and ''''CDD Output'''' to EiffelStuio. By default they are not visible. Make them visible by going to the menu ''''View -> Tools'''' and select ''''Testing'''' and ''''CDD Output'''':
+
This adds full unit testing support to EiffelStudio. It is similar to the xUnit family of testing tools. Each test case that contains the word ''''TEST'''' in its name and inherits from class ''''CDD_TEST_CASE'''' is automatically considered a test class. Test cases are autmatically executed after every compilation. Execution can be restricted, disabled and individual test cases can be started in debug mode.
 +
 
 +
== Test Case Extraction ==
 +
CDD observs the developer while running the program under development. Whenever an exception is thrown CDD gets activated automatically and extracts a test cases that is able to reproduce the observed failure. Once a test case is extracted it shows up in the test case view and behaves like an ordinary manually written test cases.
  
 
[[Image:enable_cdd.png|center]]
 
[[Image:enable_cdd.png|center]]

Revision as of 06:40, 28 January 2008


Getting Started

The following will first give a quick overview of the two main features of CDD and then guide you through enabling and using them.

The two main feature of CDD are test case exectution and test case extraction.

Test Case Execution

This adds full unit testing support to EiffelStudio. It is similar to the xUnit family of testing tools. Each test case that contains the word 'TEST' in its name and inherits from class 'CDD_TEST_CASE' is automatically considered a test class. Test cases are autmatically executed after every compilation. Execution can be restricted, disabled and individual test cases can be started in debug mode.

Test Case Extraction

CDD observs the developer while running the program under development. Whenever an exception is thrown CDD gets activated automatically and extracts a test cases that is able to reproduce the observed failure. Once a test case is extracted it shows up in the test case view and behaves like an ordinary manually written test cases.

Enable cdd.png

The two main features of CDD are test case execution and test case extraction. The first will cause the execution of your test cases after every compilation and the second will extract a new test case after every exception is thrown. By default both features are disabled. Enable both by pressing the two toolbar buttons marked in red below:

Enable exec and extract.png

How to add a manual test case

To add a manual test case simply create a new class whose name contains the word 'TEST', have it inherit from CDD_TEST_CASE and add one or several unit test routines. Make sure that all unit test routines start with 'test_'. Here is a simple example test class:

class TEST_BANK_ACCOUNT
inherit CDD_TEST_CASE
feature
  test_deposit
    local
      ba: BANK_ACCOUNT
    do
      create ba.make_with_balance (0)
      ba.deposit (100)
      check
         money_depisited: ba.balance = 100
      end
    end
end

After you have added your test class, recompile and your test case should automatially appear in the 'Testing' tool window. A template test case can be created by pressing the 'Create new manual test case' button:

Create test case.png

How to extract a test case

CDD automatically extracts a new test case after every thrown exception. This test case will appear in the normal test case tool window and can be managed like an ordinary manually written test case.

How to search for a test case

Use the filter text box to search for test case by name or tag. Make sure you press enter after you have changed the filter text.

How to add a tag to a test case

You can add custom tags to test cases by adding a indexing item 'tag' to either the test class or the test routine. Here is an example of a test class with a tag:

indexing
  tag: "fixme"
class TEST_BANK_ACCOUNT
inherit CDD_TEST_CASE
feature
  test_deposit
    local
      ba: BANK_ACCOUNT
    do
      create ba.make_with_balance (0)
      ba.deposit (100)
      check
         money_depisited: ba.balance = 100
      end
    end
end


How to restrict test case execution

If the 'Restrict' push-button is pressed, only test cases matching the current filter criterion (i.e. test cases that show up in the tree-view) will be executed. You can use this to shorten testing time when working on a particular subset of your program.

How to debug a test case

To debug ...