mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-07-18 13:57:38 +00:00
Using `t` instead of `tCtx` is subtly wrong: the failure is attributed to the parent test, not the sub-test. Using a separate function with tCtx as parameter ensures that t is not in scope of the code and thus this mistake cannot happen. The number of lines is the same, it's just a bit more code. For TestRetry another advantage is the reduced indention. It's worth calling out that the same cannot be done for benchmarks: - They need methods (Loop) or fields (N) which are not exposed by TContext. - The `for b.Loop()` pattern only works if the for loop is written exactly like that.