A POC for testing your code, only with comments.
MIT License
Testa is the best, simple Test tool "CrossPlatform" and "CrossLanguages" (Only Script languages supported for now), develop by developpers for developpers based on comments in your code. The power in this tool is that the grammar is the same for all your implementation languages.
Note: This project is completly experimental, am still working on it, not sure where am going with it lol.
List of languages, where you can perform testa test:
Some few things to know before using testa.
You need to config a testa.json
.
Javascript
:{
"module": "ta-js",
"path": ["./square.js", "./my_javascript_app/"],
"extensions": [".js"],
"launcher": "node"
}
ps : in path
parameter, you can define either a file or a directory
PHP
:{
"module": "ta-php",
"path": ["./square.php"],
"extensions": [".php"],
"launcher": "php"
}
python
:{
"module": "ta-py",
"path": ["./sha256.py", "./square.py"],
"extensions": [".py"],
"launcher": "python"
}
Ruby
:{
"module": "ta-rb",
"path": ["./my_ruby_app/", "./square.rb"],
"extensions": [".rb"],
"launcher": "ruby"
}
To install testa, it's really simple, you just have to run:
pip install tsta
# Then cd to the directory tha tcontain your testa.json file
# and run :
tsta
# That's all, a report will be generated
In your code, make sure to enclose the instructions you want to test with the testa grammar, for example:
# For a Simple assertion:
# ::import_start::
# --- Your imports here, if your methods need them ---
# ::import_end::
# ::testa_start::
# ::case_start::
# >> testa.isEqual(2, 2)
# << true
# ::case_end::
# ::testa_end::
#
# ::doc_start::
# .
# Here a small description of the function that will be generate on the documentation
# .
# ::doc_end::
#
# With methods :
# ::testa_start::
# ::case_start::
# >> addition(2, 2)
# << 4
# ::case_end::
# ::code_start::
def addition(a, b):
return a+b
# ::code_end::
# ::testa_end::
// ::import_start::
// --- Your imports here ---
// ::import_end::
// For a Simple assertion:
// ::testa_start::
// ::case_start::
// >> testa.isEqual(2, 2)
// << true
// ::case_end::
// ::testa_end::
// For more instructions:
// ::testa_start::
// ::case_start::
// >> addition(2, 2)
// << 4
// ::case_end::
//
// ::doc_start::
// .
// Here a small description of the function that will be generate on the documentation
// .
// ::doc_end::
//
// ::code_start::
// --- Your specific list of instruction / functions source code here!
function addition(a, b){
return a+b
}
// ::code_end::
// ::testa_end::
// ::testa_start::
// ::case_start::
// >> square(9)
// << 3
// ::case_end::
// ::code_start::
function square($a){
return sqrt($a);
}
// ::code_end::
// ::testa_end::
# ::testa_start::
# ::case_start::
# >> square(9)
# << 3.0
# ::case_end::
# ::code_start::
def square(a)
return a/2
# ::code_end::
# ::testa_end::
And that's where the magic of Testa is, for any language, you have only to write a simple JSON file and specify paths where you will do tests.