MCPcopy Index your code
hub / github.com/gavv/httpexpect / TestAssertion_Handler

Function TestAssertion_Handler

assertion_test.go:11–142  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestAssertion_Handler(t *testing.T) {
12 type test struct {
13 formatter *mockFormatter
14 reporter *mockReporter
15 logger *mockLogger
16
17 handler *DefaultAssertionHandler
18 }
19
20 createTest := func(t *testing.T, enableLogger bool) test {
21 var test test
22
23 test.handler = &DefaultAssertionHandler{}
24
25 test.formatter = newMockFormatter(t)
26 test.handler.Formatter = test.formatter
27
28 test.reporter = newMockReporter(t)
29 test.handler.Reporter = test.reporter
30
31 if enableLogger {
32 test.logger = newMockLogger(t)
33 test.handler.Logger = test.logger
34 }
35
36 return test
37 }
38
39 t.Run("success", func(t *testing.T) {
40 test := createTest(t, true)
41
42 test.handler.Success(&AssertionContext{
43 TestName: t.Name(),
44 })
45
46 assert.Equal(t, 1, test.formatter.formattedSuccess)
47 assert.Equal(t, 0, test.formatter.formattedFailure)
48
49 assert.True(t, test.logger.logged)
50 assert.False(t, test.reporter.reported)
51 })
52
53 t.Run("success, no logger", func(t *testing.T) {
54 test := createTest(t, false)
55
56 test.handler.Success(&AssertionContext{
57 TestName: t.Name(),
58 })
59
60 assert.Equal(t, 0, test.formatter.formattedSuccess)
61 assert.Equal(t, 0, test.formatter.formattedFailure)
62
63 assert.Nil(t, test.logger)
64 assert.False(t, test.reporter.reported)
65 })
66
67 t.Run("failure, severity info", func(t *testing.T) {
68 test := createTest(t, true)

Callers

nothing calls this directly

Calls 9

newMockFormatterFunction · 0.85
newMockReporterFunction · 0.85
newMockLoggerFunction · 0.85
TrueMethod · 0.80
FalseMethod · 0.80
SuccessMethod · 0.65
NameMethod · 0.65
FailureMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…