Tests should be aligned with what they claim to validate, and placed at the right layer (unit vs integration). Concretely:
uname -r, not just that the command succeeded). For CLI/progress rendering, assert the actual emitted bytes (use a Pipe, read raw output, check \n vs \r, and ensure no extra lines)./dev/urandom), add sync before/after, and assert on measurable effects rather than assuming timing.Example pattern for meaningful terminal assertions:
func testPlainModeTerminalOutput() async throws {
let pipe = Pipe()
let config = try ProgressConfig(
terminal: pipe.fileHandleForWriting,
description: "Task",
outputMode: .plain
)
let progress = ProgressBar(config: config)
progress.render(force: true)
progress.finish()
try pipe.fileHandleForWriting.close()
let data = pipe.fileHandleForReading.readDataToEndOfFile()
let output = String(decoding: data, as: UTF8.self)
#expect(output.components(separatedBy: "\n").count == 3) // exactly two lines
}
Apply the same idea to other “claim vs reality” gaps: if the test name implies a behavior, the assertions must directly observe it.