Sanity check, nykterhetstest

In a (unit) test I sometimes add extra tests to check the test tests what is anticipated.

user = new User(Id="A", Name = "N1")
sut.Create(user)
saved = sut.Get("A")

saved.Name.Should.Be("N1", "Sanity check we know what we have stored.")

// Act.
sut.Clear("A")

// Assert.
result = sut.Get("A")
result.Name.Should.Be(null)

Notice the “sanity check” to verify a bug didn’t set Name to null when creating the user.

My naming convention is “Sanity check” or “Nykterhetskontroll” in Swedish.
[I know the translation, word per word, is incorrect.]

Tags: ,

Leave a Reply