common test 记录
来源:互联网 发布:端口出现感叹号 编辑:程序博客网 时间:2024/06/06 07:19
erlang 字符串连接要用string:concat/2或string:join/2,不能用++
以GUI方式启动common test
ct_run -vts -browser firefox -config cfg/test.cfg -logdir logs/ -dir ./ -erl_args -pa /home/louieli/work/test/itf -s inets start
命令行方式启动ct
首先修改erlang启动文件start.boot,配置inets为默认启动
louieli@ubuntu:~$ cp /usr/local/lib/erlang/releases/R14B03/start.script my.script
louieli@ubuntu:~$ vim my.script
{apply,{application,start_boot,[kernel,permanent]}},
{apply,{application,start_boot,[stdlib,permanent]}},
{apply,{application,start_boot,[inets,permanent]}},
louieli@ubuntu:~$ erl
Erlang R14B03(erts-5.8.4) [source] [smp:2:2] [rq:2] [async-threads:0] [hipe][kernel-poll:false]
Eshell V5.8.4 (abort with ^G)
1>systools:script2boot("my").
ok
louieli@ubuntu:/usr/local/lib/erlang/bin$sudo mv start.boot start.boot.bak
louieli@ubuntu:/usr/local/lib/erlang/bin$sudo mv ~/my.boot start.boot
在home目录建.erlang文件,加入搜索路径
root@bt:~/dbank/test/testProduct# cat .erlang
code:add_patha("/root/dbank/test/testProduct").
code:add_patha("/root/dbank/test/itf").
ct_run -config /home/louieli/work/test/testNSP/cfg/test.cfg -logdir /home/louieli/work/test/logs/ -dir /home/louieli/work/test/testNSP -erl_args -pa /home/louieli/work/test/itf
#指定testsuite
root@bt:~/dbank/test/testProduct#ct_run -config /root/dbank/test/testProduct/cfg/production.cfg -logdir /root/dbank/test/logs/ -suite app_weibo_SUITE -erl_args -pa /root/dbank/test/itf
通过{save_config,ConfigList}和{Saver,ConfigList} =?config(saved_config,Config)只能在相邻的两个用例之间传递数据。
用例是按照在all/0中出现的先后顺序执行的
<suite_name>_SUITE.erl
end_per_testcase/2 可以通过从Config 检测 tc_status得到testcase是否通过,tc_status可以为ok,{failed,Reason},{skipped,Reason}
当testcase 因为 timetrap timeout 或 ct:abort_current_testcase/1 终止时,end_per_testcase仍会执行,只不过是在另外的进程里,不能改变testcase终止的原因和配置。其它情况 init_per_testcase 和 end_per_testcase 和 test case是在同一个进程中执行,此时,end_per_testcase 可以通过返回{fail,Reason}改变testcase失败的原因。
testcase 中的参数 config 与启动时的 config文件是不一样的。config文件配置了SUT的一些必要信息,参数config是当前test suit 和 test case 执行时的动态配置信息
ct:userdata/3
suit() 和 testcase/1 返回的[Info]数据可以用ct:userdata获得,config参数中的信息可以用?Config宏取得
privDir = ?Config(priv_dir,Config)
testcase1() ->
[{require,ftp},
{default_config,ftp,[{ftp,"my_ftp_host"},
{username,"aladdin"},
{password,"sesame"}]}]
可以用default_config 指定默认的配置
测试组之间的属性是独立的,不存在继承关系
?Config(tc_group_result,Config)
用 -dir 指定测试目录时,CT会先在指定的目录中检查是否有tes子目录,如果test子目录存在,就用test子目录作为测试目录,否则用指定的目录做为测试目录
如果init_per_suit 中 新加的config 项与 init_per_testcase中新加的config项重名的话,config中会同时存在这两个项,在testcase中用?Config取时会取到init_per_testcase中新加项的值
用例之间不要依赖
公用的部分做成单独的模块
可以用Save_Config 来在用例和test suite之间传递数据
{Save_Config,ConfigList}
{Saver,ConfigList} = ?Config(Saved_Config,Config)
{Skip_and_Save,Reason,ConfigList}
可以通过建立 testgroup 并指定 [sequence] 来 显示指定用例的顺序
Test cases in a sequence will be executed in order until they have all succeeded or until one case fails.
config file 只能通过 ct:get_config 读取,testcase中的参数Config 可以通过 ?Config读,这些信息要先在testcase中读出来才能传递
testcase的Config是独立的,若要传递数据可以用 {Save_Config,ConfigList}
- common test 记录
- Java common utils test
- 工作记录(test)
- 记录 and Test
- iOS 开发 - CollectionView Test 记录
- How much common sense have YOU got? Take the test
- 个人记录-LeetCode 14. Longest Common Prefix
- Common LISP娘好萌呀,特开一坑,专门记录
- 【疑难杂症】记录 kafka.common.ConsumerRebalanceFailedException:异常
- Test Complete的性能记录方法
- common
- common
- Common
- common
- common
- Common
- common
- poj 2127 Greatest Common Increasing Subsequence (记录路径LICS)
- 贪心算法 - 哈夫曼编码 Huffman
- 带环的链表
- 范围搜索 (Range Query)
- 黑马程序员_SQL总结一
- Problems occurred when invoking code from plug-in: "org.eclipse.jface".
- common test 记录
- 20120808 (X)HTML与CSS核心基础
- c# webbroswer 中文乱码
- CALayer
- Android应用开发提高系列(4)——Android动态加载(上)——加载未安装APK中的类
- struts2 set标签
- Ubuntu12.04安装Sun JDK 6u32
- Android应用开发提高系列(5)——Android动态加载(下)——加载已安装APK中的类和资源
- 查看本机DNS linux