This script automates stress testing by comparing the outputs of a correct solution and a potentially incorrect solution on randomly generated test cases. It helps identify edge cases where the incorrect solution fails.
- Automates the generation of test cases.
- Compares outputs of two solutions (
correct.pyandwrong.py). - Saves failing test cases for debugging.
- Supports multiple programming languages: C, C++, Java, Python.
test.py: The main script to run the stress tests.generator.py: Generates random test cases.correct.py: The correct solution.wrong.py: The solution being tested for errors.delete.py: To delete all the testcases.run_test.bat: Batch script for easy execution on Windows.run_test.sh: Script for easy execution on Linux.
- Python installed on your system.
- Required compilers (if testing C, C++, or Java solutions).
- Place all required files (
test.py,generator.py,correct.py,wrong.py) in the same directory. - Use the batch file for simplified execution:
For Ubuntu
./run_test
bash run_test.sh
- To delete all the testcases:
python delete.py
To test solutions written in languages other than Python:
- Rename or specify the correct solution and wrong solution files with appropriate extensions.
For C:correct.c,wrong.c
For C++:correct.cpp,wrong.cpp
For Java:correct.java,wrong.java - Change the Script accordingly
For C:python test.py -g generator.py -c correct.c -w wrong.c -t 10
For C++:python test.py -g generator.py -c correct.cpp -w wrong.cpp -t 10
For Java:python test.py -g generator.py -c correct.java -w wrong.java -t 10