Skip to content

Commit a9a9c89

Browse files
committed
docs cleaned and simplify, remove wordiness
1 parent 4e2a07a commit a9a9c89

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

assert/doc.go

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
Package assert includes runtime assertion helpers both for normal execution as
33
well as a assertion package for Go's testing. What makes solution unique is its
4-
capable to support both modes with same API. Only thing you need to do is to
4+
capable to support both modes with the same API. Only thing you need to do is to
55
add a PushTester line at the beginning of your unit tests:
66
77
func TestInvite(t *testing.T) {
@@ -13,13 +13,13 @@ add a PushTester line at the beginning of your unit tests:
1313
1414
# Merge Runtime And Unit Test Assertions
1515
16-
Especially powerful feature is that even if some assertion violation happens
17-
during the execution of called functions, and not the test function itself, they
18-
are catched. See the above example. If assertion failure happens inside the
19-
Invite() function instead of the actual test function, TestInvite, it's still
20-
reported correctly as normal test failure. It doesn't matter how deep the
21-
recursion is, or if parallel test runs are performed. It works just as you
22-
hoped.
16+
If some assertion violation happens in the deep call stack, they are still
17+
reported as a test failure. See the above example. If assertion failure happens
18+
somewhere inside the Invite() functions call stack, it's still reported
19+
correctly as a test failure of the TestInvite. It doesn't matter how deep the
20+
recursion is, or if parallel test runs are performed. The failure report
21+
includes all the locations of the meaningful call stack steps. See the chapter
22+
Call Stack Traveral During Tests.
2323
2424
This is the actual Invite function implementation's first two lines. Even if the
2525
assertion line is written more for runtime detection and active comment, it
@@ -28,16 +28,12 @@ catches all unit test errors as well:
2828
func (c Chain) Invite(...) {
2929
assert.That(c.isLeaf(invitersKey), "only leaf can invite")
3030
31-
# Call Stack Traversal During tests
31+
# Call Stack Traversal During Tests
3232
33-
The asserter package has super powerful feature. It allows us track assertion
34-
violations over package and even module boundaries. When using err2 assert
35-
package for runtime Asserts and assert violation happens in whatever package
36-
and module, the whole call stack is brought to unit test logs. Naturally this is
37-
optional. Only thing you need to do is set proper asserter and call PushTester.
38-
39-
// use unit testing asserter
40-
assert.SetDefault(assert.TestFull)
33+
Assert package allows us track assertion violations over package and even module
34+
boundaries. When an assertion fails during the unit testing, the whole call
35+
stack is brought to unit test logs. And some help with your IDE, that output can
36+
be tranferred to a location list, for examplem in Neovim/Vim.
4137
4238
With large multi repo environment this has proven to be valuable.
4339

0 commit comments

Comments
 (0)