MCPcopy
hub / github.com/stretchr/testify / TestAfterTotalWaitTimeWhileExecution

Function TestAfterTotalWaitTimeWhileExecution

mock/mock_test.go:2203–2227  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2201}
2202
2203func TestAfterTotalWaitTimeWhileExecution(t *testing.T) {
2204 t.Parallel()
2205
2206 waitDuration := 1
2207 total, waitMs := 5, time.Millisecond*time.Duration(waitDuration)
2208 aTimer := new(timer)
2209 for i := 0; i < total; i++ {
2210 aTimer.On("GetTime", i).After(waitMs).Return(fmt.Sprintf("Time%d", i)).Once()
2211 }
2212 time.Sleep(waitMs)
2213 start := time.Now()
2214 var results []string
2215
2216 for i := 0; i < total; i++ {
2217 results = append(results, aTimer.GetTime(i))
2218 }
2219
2220 end := time.Now()
2221 elapsedTime := end.Sub(start)
2222 assert.True(t, elapsedTime > waitMs, fmt.Sprintf("Total elapsed time:%v should be at least greater than %v", elapsedTime, waitMs))
2223 assert.Equal(t, total, len(results))
2224 for i := range results {
2225 assert.Equal(t, fmt.Sprintf("Time%d", i), results[i], "Return value of method should be same")
2226 }
2227}
2228
2229func TestArgumentMatcherToPrintMismatch(t *testing.T) {
2230 t.Parallel()

Callers

nothing calls this directly

Calls 7

TrueFunction · 0.92
EqualFunction · 0.92
OnceMethod · 0.80
ReturnMethod · 0.80
AfterMethod · 0.80
GetTimeMethod · 0.80
OnMethod · 0.45

Tested by

no test coverage detected