deles 发表于 2012-9-16 19:08:48

Openstack 单元测试

本帖最后由 deles 于 2012-9-16 19:09 编辑


1./run_tests.sh

这样会对整个nova工程进行一次测试,会花不少时间。这个脚本里封装了nose测试框架的用法,关于nose可以自己搜索相关资源。这个脚本支持许多不同的参数以获得相应的信息,具体参数如下:


01Usage: ./run_tests.sh ...


02Run Nova's test suite(s)


03



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


2



3#对libvirt模块中的HostStateTestCase类做测试


4



5./run_tests.sh test_utils:ToPrimitiveTestCase.test_dict


6



7#对ToPrimitiveTestCase.test_dict方法做测试

2.控制输出    默认情况下,执行测试之后,会在控制台输出大量的测试信息,在这些输出中找到想要的结果还是比较困难的,即便是重定向到文件中,依然不是很方便,这样就需要控制测试的输出结果。在执行测试的时候添加一个参数就可以:


1--nologcapture

5ol.cc 发表于 2013-3-13 17:21:15

有道理。。。

falldog 发表于 2013-5-15 18:46:10

我的id是假冒的,大家不要相信我是骗子。

zpjx 发表于 2013-5-16 04:20:49

流氓不可怕,就怕流氓有文化。

dog1888 发表于 2013-5-16 17:39:39

老天,你让夏天和冬天同房了吧?生出这鬼天气!

sol229 发表于 2013-5-17 11:12:57

一时的冲动,子孙的危机!

jonvi 发表于 2013-5-17 22:13:40

站的更高,尿的更远。
页: [1]
查看完整版本: Openstack 单元测试