failure causes dependent tests to be skipped
parent
10508bceeb
commit
094ecccb5a
@ -1,32 +1,46 @@
|
|||||||
package tea
|
package tea
|
||||||
|
|
||||||
import "testing"
|
import (
|
||||||
|
// "reflect"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
// Run runs a tree of tests, starting from its root.
|
// Run runs a tree of tests, starting from its root.
|
||||||
func Run(t *testing.T, tree *Tree) {
|
func Run(t *testing.T, tree *Tree) {
|
||||||
plan := tree.plan()
|
plan := tree.plan()
|
||||||
t.Logf("steps in plan: %d", len(plan))
|
for _, step := range plan {
|
||||||
for _, start := range plan {
|
t.Run(step.name, step.run)
|
||||||
t.Logf("start test %T: %#v", start.Test, start.Test)
|
|
||||||
start.run(t)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(test Test) *Tree {
|
func New(test Test) *Tree {
|
||||||
return &Tree{Test: test}
|
return &Tree{
|
||||||
|
Test: test,
|
||||||
|
name: parseName(test),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type Tree struct {
|
type Tree struct {
|
||||||
Test
|
Test
|
||||||
|
name string
|
||||||
parent *Tree
|
parent *Tree
|
||||||
children []*Tree
|
children []*Tree
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Tree) Child(test Test) *Tree {
|
func (t *Tree) Child(test Test) *Tree {
|
||||||
child := &Tree{
|
child := New(test)
|
||||||
Test: test,
|
child.parent = t
|
||||||
parent: t,
|
|
||||||
}
|
|
||||||
t.children = append(t.children, child)
|
t.children = append(t.children, child)
|
||||||
return child
|
return child
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func parseName(test Test) string {
|
||||||
|
if s, ok := test.(interface{ String() string }); ok {
|
||||||
|
return s.String()
|
||||||
|
}
|
||||||
|
return "???"
|
||||||
|
// T := reflect.TypeOf(test)
|
||||||
|
// for i := 0; i < T.NumField(); i++ {
|
||||||
|
// field := T.Field(i)
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue