From: Thomas Walker Lynch
IO ObjectEach test function is given an IO object, which provides
- methods for inspecting stdout and stderr output
- streams, programmatically adding data to the stdin input stream,
- and clearing output streams as needed. Although the IO object is
- optional, it is available for cases where I/O validation or cleanup is
- essential to the test.
Each test function is responsible for managing any output generated
- on stdout or stderr by the function under test
- (fut). TestBench will automatically clear the streams before
- each test begins and will check them after the test completes, treating any
- remaining output as unintended and marking the test as a failure. This policy
- ensures that tests intentionally handle output by either validating,
- clearing, or ignoring it, thereby maintaining a clean and predictable testing
- environment.
stdout and stderr using methods like io.get_out_content() or io.get_err_content(). The test passes if the actual output matches the expected content.io.clear_buffers()) if further output handling is not needed to avoid residual content.TestBench that any output generated was intentionally disregarded and avoids marking the test as failed.TestBench will flag this as a failure.public static Boolean test_with_output_verification(IO io) {
- System.out.println("Expected output");
- String output = io.get_out_content();
- boolean isCorrect = output.equals("Expected output");
- io.clear_buffers(); // Clear remaining content if not needed
- return isCorrect;
-}
-
- public static Boolean test_without_output_verification(IO io) {
- System.out.println("Output not needed for this test");
- io.clear_buffers(); // Clear output since itâs intentionally ignored
- return true;
-}
-
-
- Each test should manage its output streams with an intentional policy:
-TestBench from marking the test as failed.This approach ensures that tests remain clean and focused on their primary objectives without unintended side effects from unhandled output.
-IO ObjectEach test function is given an IO object, which provides
+ methods for inspecting stdout and stderr output
+ streams, programmatically adding data to the stdin input stream,
+ and clearing output streams as needed. Although the IO object is
+ optional, it is available for cases where I/O validation or cleanup is
+ essential to the test.
Each test function is responsible for managing any output generated
+ on stdout or stderr by the function under test
+ (fut). TestBench will automatically clear the streams before
+ each test begins and will check them after the test completes, treating any
+ remaining output as unintended and marking the test as a failure. This policy
+ ensures that tests intentionally handle output by either validating,
+ clearing, or ignoring it, thereby maintaining a clean and predictable testing
+ environment.
stdout and stderr using methods like io.get_out_content() or io.get_err_content(). The test passes if the actual output matches the expected content.io.clear_buffers()) if further output handling is not needed to avoid residual content.TestBench that any output generated was intentionally disregarded and avoids marking the test as failed.TestBench will flag this as a failure.public static Boolean test_with_output_verification(IO io) {
+ System.out.println("Expected output");
+ String output = io.get_out_content();
+ boolean isCorrect = output.equals("Expected output");
+ io.clear_buffers(); // Clear remaining content if not needed
+ return isCorrect;
+}
+
+ public static Boolean test_without_output_verification(IO io) {
+ System.out.println("Output not needed for this test");
+ io.clear_buffers(); // Clear output since itâs intentionally ignored
+ return true;
+}
+
+
+ Each test should manage its output streams with an intentional policy:
+TestBench from marking the test as failed.This approach ensures that tests remain clean and focused on their primary objectives without unintended side effects from unhandled output.
+