title: Literals or expressions in unit test asserts?
body: <p>Do you prefer literal values or expressions in your Asserts in your unit tests? This little example demonstrates what I mean - please pay attention to the comments:</p>
  
  <pre><code>[Test]
  public function fromXML_works() : void {
      var slideshow : Slideshow = SlideshowConverter.fromXML(xmlSample);
  
      // do you prefer literal value "1":
      assertEquals(slideshow.id, "1");
  
      // ... or an expression like this:
      assertEquals(slideshow.id, xmlSample.@id);
  }
  
  
  private var xmlSample : XML =
      &lt;slideshow id="1"&gt;
          &lt;someOtherTags /&gt;
      &lt;/slideshow&gt;;
  </code></pre>
  
  <p>The nice thing about the expression is that when the XML sample changes, the unit test will not break. On the other hand, I've basically provided an <em>implementation</em> of one aspect of my SlideshowConverter directly in my unit test which I don't like (the test should test intent, not implementation). I can also imagine that tests using expressions will be more prone to programming errors (I could have, for example, made a mistake in my E4X expression in my test method).</p>
  
  <p>What approach do you prefer? What advantage is usually more important on real world projects?</p>