本帖最后由 deles 于 2012-9-16 19:09 编辑
这样会对整个nova工程进行一次测试,会花不少时间。这个脚本里封装了nose测试框架的用法,关于nose可以自己搜索相关资源。这个脚本支持许多不同的参数以获得相应的信息,具体参数如下:
01 | Usage: ./run_tests.sh [OPTION]... |
02 | Run Nova's test suite(s) |
04 | -V, --virtual-env Always use virtualenv. Install automatically if not present |
05 | -N, --no-virtual-env Don't use virtualenv. Run tests in local environment |
06 | -s, --no-site-packages Isolate the virtualenv from the global Python environment |
07 | -r, --recreate-db Recreate the test database (deprecated, as this is now the default). |
08 | -n, --no-recreate-db Don't recreate the test database. |
09 | -x, --stop Stop running tests after the first error or failure. |
10 | -f, --force Force a clean re-build of the virtual environment. Useful when dependencies have been added. |
11 | -p, --pep8 Just run pep8 |
12 | -P, --no-pep8 Don't run pep8 |
13 | -c, --coverage Generate coverage report |
14 | -h, --help Print this usage message |
15 | --hide-elapsed Don't print the elapsed time for each test along with slow test list |
上面是对整个工程的测试,如果仅想对某个模块或功能做测试的话,可以运行相应的测试子集:
1 | ./run_tests.sh scheduler |
2 | #测试 <span>nova/tests/scheduler</span> |
上面的代码是对nova调度器模块做的测试,也可以对模块中的具体类或方法做测试,如下:
1 | ./run_tests.sh test_libvirt:HostStateTestCase |
3 | #对libvirt模块中的HostStateTestCase类做测试 |
5 | ./run_tests.sh test_utils:ToPrimitiveTestCase.test_dict |
7 | #对ToPrimitiveTestCase.test_dict方法做测试 |
2.控制输出 默认情况下,执行测试之后,会在控制台输出大量的测试信息,在这些输出中找到想要的结果还是比较困难的,即便是 重定向到文件中,依然不是很方便,这样就需要控制测试的输出结果。在执行测试的时候添加一个参数就可以:
|