Documentation ¶
Overview ¶
This package hold simple unit testing helper used in rcc tests.
Package rcc/hamlet provides DSL for writing terse declarative runnable specifications.
When you want to use Hamlet for runnable specifications, first thing in your specifications should be wrapping *testing.T with "hamlet.Specifications(t)" and you get back two parts, one for positive declarations and one for negative ("to be" and "not to be"; "must be" and "wont be"; "be" and "not").
func TestWrapsTestingT(t *testing.T) { to_be, not_to_be := hamlet.Specifications(t) ... }
And then you have set of predicates to declare, how system should behave when used in code.
func TestToGetUnderstandingHowSystemWorks(t *testing.T) { must_be, wont_be := hamlet.Specifications(t) dirname, err := os.Getwd() must_be.Nil(err) wont_be.Nil(dirname) prefix, _ := path.Split(dirname) wont_be.Equal(prefix, dirname) must_be.True(strings.HasPrefix(dirname, prefix)) }
I like my specifications short and declarative, not longwindy and procedural code form. One line, one expectation!
Index ¶
- func Specifications(test Reporter) (*Hamlet, *Hamlet)
- type Hamlet
- func (it *Hamlet) All(property interface{})
- func (it *Hamlet) Equal(expected, actual interface{})
- func (it *Hamlet) Match(expected string, actual interface{})
- func (it *Hamlet) Nil(actual interface{})
- func (it *Hamlet) Panic(function Panicable)
- func (it *Hamlet) Same(expected, actual interface{})
- func (it *Hamlet) Text(expected string, actual interface{})
- func (it *Hamlet) True(actual bool)
- func (it *Hamlet) Type(expected string, actual interface{})
- type Panicable
- type Reporter
Constants ¶
This section is empty.
Variables ¶
This section is empty.