View on GitHub

BellaCode

by Geoff Cox

Software Craftsman. Guitarist. Folk Hero.

Name your variables with the Expected, Target, Actual pattern

The Expected, Target, Actual (ETA) pattern distinguishes the entities you use for each step of your test.

Pattern

Example

    [TestMethod()]
    public void WhenNameSetThenValueUpdated()
    {
      // Arrange
      var expected = "Name";
    
      var id = new Guid("04360d3f-76bb-42c7-96dc-982934c39a3c");
      var publishedLocation = "PublishedLocation";
    
      var target = new Enlistment(id, publishedLocation);
    
      // Act
      target.Name = expected;
      var actual = target.Name;
    
      // Assert                                  
      Assert.AreEqual(expected, actual);
    }

Tips

Benefits