Skip to content

Commit

Permalink
update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
lainio committed Mar 13, 2024
1 parent 809b9aa commit bbf72e7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions assert/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Package assert includes runtime assertion helpers both for normal execution as
well as a assertion package for Go's testing. What makes solution unique is its
capable to support both modes with same API. Only thing you need to do is to
add following two lines at the beginning of your unit tests:
add a PushTester line at the beginning of your unit tests:
func TestInvite(t *testing.T) {
defer assert.PushTester(t)() // push testing variable t beginning of any test
Expand All @@ -14,14 +14,14 @@ add following two lines at the beginning of your unit tests:
# Merge Runtime And Unit Test Assertions
Especially powerful feature is that even if some assertion violation happens
during the execution of called functions not the test function itself. See the
above example. If assertion failure happens inside of the Invite() function
instead of the actual test function, TestInvite, it's still reported correctly
as normal test failure when TestInvite unit test is executed. It doesn't matter
how deep the recursion is, or if parallel test runs are performed. It works just
as you hoped.
This is the actual Invite function implementation's first two lines. Even the
during the execution of called functions, and not the test function itself, they
are catched. See the above example. If assertion failure happens inside the
Invite() function instead of the actual test function, TestInvite, it's still
reported correctly as normal test failure. It doesn't matter how deep the
recursion is, or if parallel test runs are performed. It works just as you
hoped.
This is the actual Invite function implementation's first two lines. Even if the
assertion line is written more for runtime detection and active comment, it
catches all unit test errors as well:
Expand Down
4 changes: 2 additions & 2 deletions err2.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ var (
//
// You can have unlimited amount of error handlers. They are called if error
// happens and they are called in the same order as they are given or until one
// of them resets the error like Reset (notice other predefined error handlers)
// in the next samples:
// of them resets the error like Reset (notice the other predefined error
// handlers) in the next samples:
//
// defer err2.Handle(&err, err2.Reset, err2.Log) // Log not called
// defer err2.Handle(&err, err2.Noop, err2.Log) // handlers > 1: err annotated
Expand Down

0 comments on commit bbf72e7

Please sign in to comment.