The I/O Test is a Python program that can be used to test a CLI program using input/output (I/O) tests generated by GitHub Copilot. The program reads a text file containing the Copilot generated tests, runs the program being tested with the input values from each test case, and compares the output of the program with the expected output from the test case. If the output matches the expected output, the test is considered to have passed. If the output does not match the expected output, the test is considered to have failed and the expected and actual output are printed to the console.
- Python 3.x
- A program to be tested
- A text file containing Copilot generated tests
To use the I/O Test Runner, follow these steps:
-
Save the iotest.py file to your computer.
-
Create a text file containing the Copilot generated tests. The file should be in the following format:
Test Case 1: Enter number: 5 Enter number 3: 6 Expected Output: stdout Test Case 2: Enter number 1: 10 Enter number 2: 2 Expected Output: stdout
Each test case should be on a separate line and should contain the input values and the expected output. The input values should be separated by spaces and the expected output should be preceded by the text "Expected Output:" or "Output".
Generally copy pasting the copilot output will suffice
-
Open a command prompt or terminal window and navigate to the directory containing the iotest.py file and the test file.
-
Run the
iotest.py
program with the following command:python iotest.py <program_path> <tests_path>
- The program will run the tests and print the results to the console.
- Create a
iotest.bat
file and add the command used to runiotest.py
python path/to/iotest.py
- Add the path of your
iotest.bat
file to environment variable.- Open the Start menu and search for "Environment Variables".
- Click on "Edit the system environment variables".
- Click on the "Environment Variables" button.
- Under "System Variables", scroll down and find the "Path" variable.
- Click on "Edit".
- Click on "New" and add the path of your
iotest.bat
file. - Click "OK" on all windows to save the changes.
- Open a terminal anywhere and run
iotest
by simply entering:iotest <program_path> <tests_path>
The I/O Test is released under the MIT License. See the LICENSE file for details.