saru is opensource (BSD) and is the simplest testing framework I could come up with.
So how do you use it?
Heres an example test in python
#!/bin/python # SARU : tag example import sys print >> sys.stderr, "Log message" sys.exit(1)
The same thing again in C++
The convention is that tests are single applications that return 1 for failure and 0 for success. To distinguish test files from other files such as mocks, fixtures or other helper code, tests are tagged with a SARU tag. Now to run these tests// SARU : tag example #include <iostream> int main() { std::cerr << "Log message" << std::endl ; return 1; }
saru-run-tests suiteWe get the following output:
Lets change both of those files to return 0 and rerun the tests and we should getexample00.py : FAILED??? ==MESSAGE== saru-run-test : execution of test failed with error code 1 ==STDERR== Log message example01.cpp : FAILED??? ==MESSAGE== saru-run-test : execution of test failed with error code 1 ==STDERR== Log message 0 / 2
Now this should also catch and report compilation errors in the C++. Theres a bunch of stuff not explained here that I'll detail in following posts includingexample00.py : OK example01.cpp : OK 2 / 2
- How to make multiple tests in a single file
- How to specify compiler options for C++
- What would need to happen to make saru work on windows
- How to run subsets of tests
- How to extend saru to run other languages
- What are these saru logs?
- Things that still need to be done to make saru cooler
No comments:
Post a Comment