Package httpexpect helps to write nice tests for your HTTP API.

Usage example

See example directory:


Value equality

Whenever values are checked for equality in httpexpect, they are converted to "canonical form":

- type aliases are removed
- numeric types are converted to float64
- non-nil interfaces pointed to nil slices and maps are replaced with
  nil interfaces

This is equivalent to subsequently aplying json.Marshal() and json.Unmarshal() to value.

Failure handling

When some check fails, failure is reported. If non-fatal failures are used (see Checker), execution is continued and instance that was checked is marked as failed.

If specific instance is marked as failed, all subsequent checks are ignored for this instance and any child instances retreived after failure.


array := NewArray(NewAssertChecker(t), []interface{}{"foo", 123})

e0 := array.Element(0)  // success
e1 := array.Element(1)  // success

s0 := e0.String()       // success
s1 := e1.String()       // failure; e1 and s1 are marked as failed, e0 and s0 are not

s0.Equal("foo")         // success
s1.Equal("bar")         // this check is ignored because s1 is marked as failed

Imports 2 package(s) ΒΆ