Nemo Extension
In short words, Nemo
is Another BDD Test Framework. We enhance the user experience when using
the original Go testing
.
This extension is bundled with Nemo
. We add quick running
or debug
entrances allowing users
to examine a single suite or case. Also, some warning information will show when some misusages
of Nemo
are detected. The configurations for the Go
VSCode extension are fully supported.
Nemo Features
- support
suite
, case
semantics for BDD testing
- informative testing report and summary
- code coverage (up to function level)
only
and skip
semantics
A simple demo for nemo:
// import nemo with .
import (
"testing"
"github.com/stretchr/testify/assert"
. "gitlab.alibaba-inc.com/distack/nemo"
)
// the main entry, this is required
func TestMain(m *testing.M) {
s := Nemo(m)
s.Run()
}
// normal test case with Nemo enhanced
func TestExample(t *testing.T) {
s := Nemo(t)
s.Before(func() {})
s.After(func() {})
s.BeforeEach(func() {})
s.AfterEach(func() {})
// simple case
s.Case("should work fine when args is empty", func() {
})
// use nemo T (nemo.T) with assert
s.Case("use nemo t with pretty output", func(t *T) {
// fail with nemo T
assert.True(t, false, "this will fail")
})
// inner suite, support nesting suites
s.Suite("SubSuite", func(s *S) {
s.Before(func() {
// do something ...
})
s.Case("case inside subsuite", func() {
})
})
// use original t
s.Case("should error when args is more then 2", func(t *testing.T) {
})
// skip a case
s.Case("-skip this case", func() {})
// skip a suite (also children suites and test cases inside)
s.Suite("-skip this suite", func(s *S) {
s.Suite("skip since parent skipped", func(s *S) {})
s.Case("skip since suite skipped", func(s *S) {})
})
// only run a case (merge if there are other 'only's)
s.Case("+only this case", func() {})
// only run a suite (merge if there are other 'only's)
s.Suite("+Only Suite", func(s *S) {
s.Case("test in only suite", func() {})
})
}