Documentation
¶
Overview ¶
Package qual implements tests and helpers for writing highly readable tests.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultWeight = 20 * 60 * time.Second
DefaultWeight is the duration it takes to fix overloaded complexity level. E.g. if complexity is 6 and you've set max to 5 this is the duration it takes to fix the code from 6 to 5.
Functions ¶
func Assert ¶ added in v0.2.0
Example ¶
// In this example the Assert call fails to show the output. The
// line just above Assert(...) will be printed for context if an
// error occurs.
val, err := []byte("an apple"), fmt.Errorf("This is an error")
Assert(t, Vars{val, err},
len(val) == 10,
err != nil,
)
Output: > val, err := []byte("an apple"), fmt.Errorf("This is an error") failed assert: len(val) == 10 val = "an apple" err = "This is an error"
Example (MissingSourceCode) ¶
When using the Assert func even though you do not have access to the source code, eg. when doing integration tests a generic output will be given.
os.Rename("assert_example_test.go", "missing.go")
defer os.Rename("missing.go", "assert_example_test.go")
msg := "Verify response status code"
resp, _ := http.Get("http://www.example.com/existing_file")
Assert(t, Vars{resp.StatusCode, msg},
resp.StatusCode == 200,
)
Output: failed assert[0] Vars[0] = 404 Vars[1] = "Verify response status code"
Example (Nil) ¶
var err error
val, err := 9, nil
Assert(t, Vars{val, err},
val == 9,
err != nil,
)
Output: > val, err := 9, nil failed assert: err != nil val = 9 err = nil
Example (Oneline) ¶
val, err := 1, fmt.Errorf("This is an error")
Assert(t, Vars{val, err}, val == 2, err == nil)
Output: > val, err := 1, fmt.Errorf("This is an error") failed assert: val == 2 failed assert: err == nil val = 1 err = "This is an error"
func CyclomaticComplexity ¶
CyclomaticComplexity fails if max is exceeded in any go files of this project.
func FixDuration ¶ added in v0.2.1
FixDuration calculates the duration to fix all overloaded complexity. Everything more complex than 14+max is timed as if 14.
func High ¶
func High(t T)
High is the same as Standard, only it includes all vendor source as well.
func LineLength ¶
SourceWidth fails if any go file contains lines exceeding maxChars. All lines are considered, source and comments.