kubernetes/test/utils/ktesting
Patrick Ohly 047682908d ktesting: replace Begin/End with TContext.Step
Manually pairing Being with End is too error prone to be useful. It had the
advantage of keeping variables created between them visible to the following
code, but that doesn't justify using those calls.

By using a callback we can achieve a few things:

- Code using it automatically shadows the parent tCtx, thus enforcing
  that within a code block the tCtx with step is used consistently.
- The code block is clearly delineated with curly braces.
- When the code block ends, the unmodified parent tCtx is automatically
  in scope again.

Downsides:

- Extra boilerplate for the anonymous function.
  Python's `with tCtx.Step(...) as tCtx: ` would be nicer.
  As an approximation of that `for tCtx := range tCtx.Step(...)` was
  tried with `Step` returning an iterator, but that wasn't very idiomatic.
- Variables created inside the code block are not visible outside of it.
2026-01-07 14:11:33 +01:00
..
examples build: remove deprecated '// +build' tag 2025-12-18 12:16:21 +01:00
initoption ktesting: support capturing log output 2024-06-26 08:11:31 +02:00
internal ktesting: support capturing log output 2024-06-26 08:11:31 +02:00
assert.go ktesting: reimplement without interface 2026-01-05 13:45:03 +01:00
assert_test.go ktesting: reimplement without interface 2026-01-05 13:45:03 +01:00
clientcontext.go ktesting: reimplement without interface 2026-01-05 13:45:03 +01:00
contexthelper.go ktesting: reimplement without interface 2026-01-05 13:45:03 +01:00
contexthelper_test.go ktesting: ut flake fix for CI 2024-02-26 07:26:20 -05:00
doc.go ktesting: add TContext 2024-02-11 10:51:38 +01:00
errorcontext.go ktesting: reimplement without interface 2026-01-05 13:45:03 +01:00
errorcontext_test.go fix: enable and fixes rules from testifylint on test package 2024-06-30 05:44:47 +00:00
helper_test.go ktesting: reimplement without interface 2026-01-05 13:45:03 +01:00
klogcontext.go ktesting: reimplement without interface 2026-01-05 13:45:03 +01:00
ktesting.go ktesting: document side effect of SetDefaultVerbosity during init 2025-07-15 12:52:27 +02:00
main_test.go ktesting: improve unit test coverage 2024-02-22 12:04:42 +01:00
signals.go ktesting: improve unit test coverage 2024-02-22 12:04:42 +01:00
signals_non_win.go build: remove deprecated '// +build' tag 2025-12-18 12:16:21 +01:00
signals_win.go build: remove deprecated '// +build' tag 2025-12-18 12:16:21 +01:00
stepcontext.go ktesting: replace Begin/End with TContext.Step 2026-01-07 14:11:33 +01:00
stepcontext_test.go ktesting: reimplement without interface 2026-01-05 13:45:03 +01:00
tcontext.go ktesting: add namespace support 2026-01-05 13:45:03 +01:00
tcontext_test.go ktesting: add namespace support 2026-01-05 13:45:03 +01:00
withcontext.go ktesting: reimplement without interface 2026-01-05 13:45:03 +01:00