Releases: maxatome/go-testdeep
Release list
v1.8.0
New features:
- add new
JSONPointeroperator following RFC 6901; - when 2 types differ but have the same short name, use full pkg name in error report;
- add Cmp and Smuggle hooks feature;
- new
td.Tupletype added and itstd.TupleFrom()builder. Useful to quickly test functions returning several values as in:price := func(p float64) (float64, string, error) { if p < 0 { return 0, "", errors.New("negative price not supported") } return p * 1.2, "€", nil } td.Cmp(t, td.TupleFrom(price(10)), td.TupleFrom(float64(12), "€", nil), ) td.Cmp(t, td.TupleFrom(price(-10)), td.TupleFrom(float64(0), "", td.Not(nil)), )
- when calling
tdhttp.NewRequest()(and all other request builder methods) headers can be flattened withtd.Flatten().
Fixes:
- missing lock when resolving anchors;
BeLaxflag (set byLaxandJSONoperators) was not taken into account for operatorsAny,Bag,Code,Contains,None,NotAny,Set,SubBagOf,SubSetOf,SuperBagOfandSuperSetOf.
Enjoy!
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.Configis now copied instead of shared before using it in sub-func; - typos in doc.
Enjoy!
v1.6.0
Changes:
td.TestingFTinterface is deprecated (but still usable) and superseded bytesting.TBstandard one: it allows to work with*testing.Binstances 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.TBif it implements aRun()method with the following signature:(X) Run(string, func(X)) bool
Breaking changes:
- as
td.TestingFTinterface is now an alias ontesting.TB, it does not containRun(string, func (*testing.T)) boolanymore; - 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
Flattenfunction: useful to flatten noninterface{}slices inSet,Bagarguments (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:
tdhttppackage (aka HTTP API tester) enhanced and fully documented;- new
Delayoperator; Containsoperator reworked, smarter and[]bytespecifically handled;String,HasPrefixandHasSuffixoperators now operate on[]bytetoo.
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
SStructoperator (and its friendsCmpSStruct&T.SStruct),
Enjoy powerful testing!
v1.1.2
New features:
- JSON expected by
JSON,SubJSONOfandSuperJSONOfoperators can now contain comments (/* … */or// …) and some simple operators can directly be embedded in JSON, as$^NotEmptyfor example; - New
SubJSONOf&SuperJSONOfoperators; - In case of error,
JSONoperator no longer truncates its JSON expected parameter in error message, but dumps all the operators involved using beautiful indented comments; - Add
Assert() *T,Require() *TandAssertRequire() (*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
Catchoperator; - New
JSONandTagoperators; - New BeLax feature with its
Laxoperator counterpart (+CmpLaxfunc) PtretPPtroperators gain someTypeBehind()capabilities.
v1.1.0
New features:
- introducing
UseEqualfeature to allow an objet to handle its comparison. SeeT.UseEqualandContextConfig.UseEqualfor 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;
Cmpfunction/method now replacesCmpDeeply(still available for backward compatibility);- Add new
KeysandValuesoperators; Code&Smuggleoperators explicitly refuse variadic functions (and so avoid uncontrolled runtime panic).
Breaking changes:
*testdeep.Tnow implementstestdeep.TestingFT:- previous
Run()method renamed toRunT(), - un-shadow
Run(string, func(t*testing.T))→ if you usedT.Runjust rename occurrences toT.RunT, NewT()handles*testdeep.Tas argument,
- previous
- Do not export
testdeep.Baseandtestdeep.BaseOKNilanymore. 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.MapIterif go≥1.12; - logo changed a little :)