This is experimental framework for generating tests on the fly. The main purpose is to use it together with code generation models, allowing to self check of generated code (by ChatGPT/GPT3 or BLOOM).
- Scan file for functions to test
- Specify tests without writing test code
- Test Python (for now) functions [In future python classes as well as other languages probably]
- Simple to use
- Lightweight
- Code embeddable
- no dependencies
pip install git+https://github.com/PeterWaIIace/BlackBoxTesting
Example of JSON defining tests:
{
"func1":{"inputs": [[1,1],[2,2],[3,3]], "outputs": [5,8,11]},
"func3":{"inputs": [[1,1],[4,2],[4,3]], "outputs": [9,16,17]}
}
Example of code:
bbTest = BBTest()
report = bbTest.generateTests('tests/test_file_python.py','tests/testing_file_for_file_scanner.json')
from BlackBoxManager import BBTest
bbTest.generateTest("hello_world","def hello_world():\n return \"hello world\"",[],["hello world"]);
report = bbTest.runTest()
from BlackBoxManager import BBTest
bbTest = BBTest()
bbTest.scanAndGenerateTest('tests/test_file_python.py','tests/testing_file_for_file_scanner.json','funcName')
report = bbTest.runTest()
- Checkout repository
- Execute
run_test.py
- Edit code in
run_test.py
ortests/test_file_python.py
- Specify test definitions in
tests/testing_file_for_file_scanner.json