Commit c5512f4c authored by Francesco Banconi's avatar Francesco Banconi

c.Run: make subtests use the parent's format function

parent a81dd65a
......@@ -145,9 +145,10 @@ func (c *C) Run(name string, f func(c *C)) bool {
panic(fmt.Sprintf("cannot execute Run with underlying concrete type %T", c.TB))
}
return r.Run(name, func(t *testing.T) {
c := New(t)
defer c.Done()
f(c)
c2 := New(t)
defer c2.Done()
c2.SetFormat(c.format)
f(c2)
})
}
......
......@@ -394,6 +394,26 @@ func TestCRunPanic(t *testing.T) {
assertBool(t, run, true)
}
func TestCRunFormat(t *testing.T) {
tt, innerTT := &testingT{}, &testingT{}
c := qt.New(tt)
c.SetFormat(func(v interface{}) string {
return fmt.Sprintf("myfmt(%v)", v)
})
c.Run("my test", func(innerC *qt.C) {
innerC.TB = innerTT
innerC.Check(42, qt.Equals, nil)
})
assertPrefix(t, innerTT.errorString(), `
error:
values are not equal
got:
myfmt(42)
want:
myfmt(<nil>)
`)
}
func TestCParallel(t *testing.T) {
tt := &testingT{}
c := qt.New(tt)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment