Releases: maxatome/go-testdeep
v1.7.0
New features:
- new (*td.T).RunAssertRequire function. Useful to avoid boilerplate code:
t.RunAssertRequire("GetAge", func (assert *td.T, require *td.T) { age, err := GetAge("Bob") require.CmpNoError(err) assert.Cmp(age, 42) })
- new tdhttp.TestAPI method Or(), useful to debug a test failure:
see the Or() documentation as the passed function can have a much more complex signature. It is inspired by Test::Mojo or() method and allows to easily inspect the response of the requested API when the checks fail.
ta.Get("/person/42", "Accept", "application/json"). CmpJSONBody(td.JSON(`{"id": $1, "name": "Bob"}`, td.NotZero())). Or(func (body string) { t.Logf("received unexpected body: <%s>", body) })
Fixes:
- #101 → some data recursion cases were not correctly handled (reported and tested by @stewi1014);
- some panics due to the user misbehavior were not properly red-colored;
- (*td.T).Run:
t.Config
is now copied instead of shared before using it in sub-func; - typos in doc.
Enjoy!
v1.6.0
Changes:
td.TestingFT
interface is deprecated (but still usable) and superseded bytesting.TB
standard one: it allows to work with*testing.B
instances as well (or any other type implementingtesting.TB
);(*td.T).RunT()
is deprecated (but still usable) and superseded by(*td.T).Run()
which now delegates totd.T.TB
if it implements aRun()
method with the following signature:(X) Run(string, func(X)) bool
Breaking changes:
- as
td.TestingFT
interface is now an alias ontesting.TB
, it does not containRun(string, func (*testing.T)) bool
anymore; - it is quite unlikely that
(*td.T).Run(string, func (*testing.T))
method is used, but if it is, all calls have to be replaced by(*td.T).Run(string, func (*td.T))
like in:note that even thoughtt.Run("my_test", func (tt *td.T) { t := tt.TB.(testing.T) ... })
(*td.T).RunT()
is deprecated, it still works as expected.
v1.5.0
New features:
- new
Flatten
function: useful to flatten noninterface{}
slices inSet
,Bag
arguments (but not only, read the doc); - panic messages due to user misuse of go-testdeep functions/methods are now red colored to help her/him to focus on her/his mistake and not think go-testdeep failed shamefully;
- delay colors initialization to the first use. So colors can now be disabled in golang playgroung. See the corresponding FAQ point;
- optimize some type retrievals.
Fix:
- forbid
Isa(nil)
because it is a nonsense and so avoid a deep panic.
New FAQ entries:
Enjoy and do not forget to star!
v1.4.0
New features:
tdhttp
package (aka HTTP API tester) enhanced and fully documented;- new
Delay
operator; Contains
operator reworked, smarter and[]byte
specifically handled;String
,HasPrefix
andHasSuffix
operators now operate on[]byte
too.
Fixes:
- anchor feature on 32 bits platforms;
- missing comments + typos.
Enjoy, but at home! ;)
v1.3.0
Package github.com/maxatome/go-testdeep
is deprecated, it is recommended to use github.com/maxatome/go-testdeep/td
in new code.
github.com/maxatome/go-testdeep
is still usable so the compatibility is preserved.
The only breaking change is the disappearance of testdeep.DefaultContextConfig
. It should be replaced by td.DefaultContextConfig
and so the go-testdeep import line should be changed (at least "github.com/maxatome/go-testdeep/td" should be added).
To summarize: migration to github.com/maxatome/go-testdeep/td
is not needed, only recommended, except if testdeep.DefaultContextConfig
is used.
To migrate:
import "github.com/maxatome/go-testdeep"
…
testdeep.DefaultContextConfig = testdeep.ContextConfig{…}
testdeep.Cmp(…)
or with "td" package alias:
import td "github.com/maxatome/go-testdeep"
…
td.DefaultContextConfig = td.ContextConfig{…}
td.Cmp(…)
simply do (see import line changes):
import "github.com/maxatome/go-testdeep/td"
…
td.DefaultContextConfig = td.ContextConfig{…}
td.Cmp(…)
See the FAQ point for details about this migration.
And still, do not forget to visit https://go-testdeep.zetta.rocks/ and open an issue if something seems to be missing or not clear.
Happy testing!
v1.2.0
New features:
- new operator anchoring feature, see the corresponding FAQ section and the new anchoring methods;
- new
SStruct
operator (and its friendsCmpSStruct
&T.SStruct
),
Enjoy powerful testing!
v1.1.2
New features:
- JSON expected by
JSON
,SubJSONOf
andSuperJSONOf
operators can now contain comments (/* … */
or// …
) and some simple operators can directly be embedded in JSON, as$^NotEmpty
for example; - New
SubJSONOf
&SuperJSONOf
operators; - In case of error,
JSON
operator no longer truncates its JSON expected parameter in error message, but dumps all the operators involved using beautiful indented comments; - Add
Assert() *T
,Require() *T
andAssertRequire() (*T, *T)
.
Enjoy powerful API testing!
v1.1.1
News:
- New web site go-testdeep.zetta.rocks;
- FAQ grew a little.
New features:
- Add some tdhttp request builders shortcuts, see
tdhttp.Get
,tdhttp.Post
,tdhttp.PostJSON
,tdhttp.PostXML
, etc. - New
Catch
operator; - New
JSON
andTag
operators; - New BeLax feature with its
Lax
operator counterpart (+CmpLax
func) Ptr
etPPtr
operators gain someTypeBehind()
capabilities.
v1.1.0
New features:
- introducing
UseEqual
feature to allow an objet to handle its comparison. SeeT.UseEqual
andContextConfig.UseEqual
for details; tdhttp.NewRequest()
,tdhttp.NewJSONRequest()
andtdhttp.NewXMLRequest()
now accept headers definition;- Test name now colored in error reports;
- Missing/Extra summaries show the number of involved items/keys;
- Extra & missing maps items are now sorted;
Cmp
function/method now replacesCmpDeeply
(still available for backward compatibility);- Add new
Keys
andValues
operators; Code
&Smuggle
operators explicitly refuse variadic functions (and so avoid uncontrolled runtime panic).
Breaking changes:
*testdeep.T
now implementstestdeep.TestingFT
:- previous
Run()
method renamed toRunT()
, - un-shadow
Run(string, func(t*testing.T))
→ if you usedT.Run
just rename occurrences toT.RunT
, NewT()
handles*testdeep.T
as argument,
- previous
- Do not export
testdeep.Base
andtestdeep.BaseOKNil
anymore. Should not be a problem. If it is, raise an issue.
Bugs fixes:
- Fix a bug when compared slices have the same backend array.
Misc:
- Switch from gometalinter to GolangCI-Lint + enable more linters;
- pre-go1.12 t.Helper() bug workaround removed as corrected upstream;
- map iterations done with
reflect.MapIter
if go≥1.12; - logo changed a little :)
v1.0.8
- ANSI colored output
- introducing helpers:
tdhttp
as first one (a.k.a. HTTP API testing helper)