<?xml version="1.0" encoding="UTF-8"?>
<org.eclipse.epf.uma:ContentDescription xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:org.eclipse.epf.uma="http://www.eclipse.org/epf/uma/1.0.6/uma.ecore" xmlns:epf="http://www.eclipse.org/epf" epf:version="1.5.1" xmi:id="_Hg5UUMPbEdmbOvqy4O0adg" name="test_first_design,_0Y6kUMlgEdmt3adZL5Dmdw" guid="_Hg5UUMPbEdmbOvqy4O0adg" changeDate="2007-06-02T14:14:20.985+0330" version="7.1.0">
  <mainDescription>&lt;h3>&#xD;
    Introduction&#xD;
&lt;/h3>&#xD;
&lt;p>&#xD;
    With Test-First Design (TFD) you do detailed design in a just-in-time (JIT) manner via writing a single test before&#xD;
    writing just enough production code to fulfill that test. When you have new functionality to add to your system,&#xD;
    perform the following steps:&#xD;
&lt;/p>&#xD;
&lt;ol>&#xD;
    &lt;li>&#xD;
        &lt;strong>Quickly add a developer test&lt;/strong>. You need just enough implementation code to fail.&amp;nbsp; For example,&#xD;
        a new method about to be added to a class could be created that just throws a fatal exception.&#xD;
    &lt;/li>&#xD;
    &lt;li>&#xD;
        &lt;strong>Run your tests&lt;/strong>. You will typically run the complete test suite, although for sake of speed you may&#xD;
        decide to run only a subset. The goal is to ensure that the new test does in fact fail.&#xD;
    &lt;/li>&#xD;
    &lt;li>&#xD;
        &lt;strong>Update your production code&lt;/strong>. The goal is to add just enough functionality so that&amp;nbsp;the code&#xD;
        passes the new test.&amp;nbsp;&#xD;
    &lt;/li>&#xD;
    &lt;li>&#xD;
        &lt;strong>Run your test suite again&lt;/strong>. If they tests fail you need to update your functional code and retest.&#xD;
        Once the tests pass, start over.&#xD;
    &lt;/li>&#xD;
&lt;/ol>&lt;br />&#xD;
&lt;p>&#xD;
    &lt;img height=&quot;600&quot; alt=&quot;Test First Design Flow&quot; src=&quot;./resources/test_first_design.jpg&quot; width=&quot;294&quot; />&#xD;
&lt;/p>&#xD;
&lt;h4>&#xD;
    Why TFD?&#xD;
&lt;/h4>&#xD;
&lt;p>&#xD;
    A significant advantage of TFD is that it enables you to take small steps when writing software, which is not only&#xD;
    safer it is also far more productive than writing code in large steps. For example, assume you add some new functional&#xD;
    code, compile, and test it. Chances are pretty good that your tests will be broken by defects that exist in the new&#xD;
    code. It is much easier to find, and then fix, those defects if you've written five new lines of code than fifty lines.&#xD;
    The implication is that the faster your compiler and regression test suite, the more attractive it is to proceed in&#xD;
    smaller and smaller steps.&#xD;
&lt;/p>&#xD;
&lt;p>&#xD;
    There are other other common testing strategies (listed here in order of effectiveness).&#xD;
&lt;/p>&#xD;
&lt;ol>&#xD;
    &lt;li>&#xD;
        &lt;strong>Write several tests first&lt;/strong>. This is a variant of TFD where you write more than one test before&#xD;
        writing just enough production code to fulfill those tests. The advantage is that you don't need to build your&#xD;
        system as often, potentially saving time. It has the disadvantage that you will write more production code at once,&#xD;
        increasing the difficulty of finding the cause of new bugs.&#xD;
    &lt;/li>&#xD;
    &lt;li>&#xD;
        &lt;strong>Test after the fact&lt;/strong>. With this approach you write some production code then you write enough&#xD;
        testing code to validate it. This has the advantage that you're at least still validating the code but has the&#xD;
        disadvantage that you lose the design benefit inherent in writing the testing code first.&#xD;
    &lt;/li>&#xD;
&lt;/ol>&lt;br />&#xD;
&lt;h3>&#xD;
    Good Things to Know&#xD;
&lt;/h3>&#xD;
&lt;p>&#xD;
    1. An underlying assumption of TFD is that a unit-testing framework is available. Agile software developers often use&#xD;
    the xUnit family of open source tools, such as &lt;a href=&quot;http://www.junit.org/&quot;>&lt;strong>JUnit&lt;/strong>&lt;/a> or &lt;a&#xD;
    href=&quot;http://www.vbunit.org/&quot;>&lt;strong>VBUnit&lt;/strong>&lt;/a>, although commercial tools are also viable options.&#xD;
&lt;/p>&#xD;
&lt;p>&#xD;
    2. Test-Driven Design (TDD) = TFD + &lt;a class=&quot;elementLink&quot; href=&quot;./../../../openup/guidances/concepts/refactoring.html&quot;&#xD;
    guid=&quot;_Poc7IPDzEdqYgerqi84oCA&quot;>Refactoring&lt;/a>&#xD;
&lt;/p>&#xD;
&lt;p>&#xD;
    3. TFD/TDD is commonly used with object-oriented business code, although this approach can be taken with procedural&#xD;
    code, user-interface code, and database code.&#xD;
&lt;/p></mainDescription>
</org.eclipse.epf.uma:ContentDescription>
