This new feature addresses cases where an assertion failure early in a test should kill a test immediately. Here are a few examples of how we've approached this up until this PR:
Length checks before assertions:
Old way:
if !this.So(collection, should.HaveLength, 2) {
return // we don't have enough items in the collection for upcoming assertions
}
this.So(collection[1].Whatever, should.Equal, "something")
... // more assertions may follow
New way:
this.So(collection, must.HaveLength, 2) // <- new 'must' package ends failed test immediately
this.So(collection[1].Whatever, should.Equal, "Something")
...via
*testing.T.Fatalf
.This change is meant to be released in concert with https://github.com/smarty/assertions/pull/55, which introduces a new
must
package.This new feature addresses cases where an assertion failure early in a test should kill a test immediately. Here are a few examples of how we've approached this up until this PR:
Length checks before assertions:
Old way:
New way:
Error checking before subsequent assertions:
Old way:
New way: