Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It's simple really. Red, Green, Refactor.</p> <p>Red means - your code is completely broken. The syntax highlighting shows red and the test doesn't pass. Why? You haven't written any code yet.</p> <p>Green means - Your application builds and the test passes. You've added the required code.</p> <p>Refactor means - clean it up and make sure the test passes.</p> <p>You can start by writing a test somewhat like this:</p> <pre><code>[TestMethod] public void Can_Create_MathClass() { var math = new MathClass(); Assert.IsNotNull(math); } </code></pre> <p>This will fail (<strong>RED</strong>). How do you fix it? Create the class.</p> <pre><code>public class MathClass { } </code></pre> <p>That's it. It now passes (<strong>GREEN</strong>). Next test:</p> <pre><code>[TestMethod] public void Can_Add_Two_Numbers() { var math = new MathClass(); var result = math.Add(1, 2); Assert.AreEqual(3, result); } </code></pre> <p>This also fails (<strong>RED</strong>). Create the <code>Add</code> method:</p> <pre><code>public class MathClass { public int Add(int a, int b) { return a + b; } } </code></pre> <p>Run the test. This will pass (<strong>GREEN</strong>).</p> <p>Refactoring is a matter of cleaning up the code. It also means you can remove redundant tests. We know we have the <code>MathClass</code> now.. so you can completely remove the <code>Can_Create_MathClass</code> test. Once that is done.. you've passed <strong>REFACTOR</strong>, and can continue on.</p> <p>It is important to remember that the Refactor step doesn't just mean your normal code. It also means tests. You cannot let your tests deteriorate over time. You must include them in the Refactor step.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload