利用linux shell script来测试linux c程序------脚本自动化测试用例代替手动测试用例
来源:互联网 发布:定格动画制做软件 编辑:程序博客网 时间:2024/06/05 22:52
我们来看一个简单的C程序:
#include <stdio.h>#include <string.h>int isGoodString(const char *p){if(strstr(p, "Good")){return 0;}return -1;}int main(int argc, char *argv[]){if(2 != argc){printf("para error\n");return -1;}if(0 == isGoodString(argv[1])){printf("yes\n");return 0;}printf("no\n");return 1;}现在, 我们来测试一下:
[taoge@localhost learn_c]$ gcc test.c [taoge@localhost learn_c]$ ./a.out para error[taoge@localhost learn_c]$ ./a.out 12no[taoge@localhost learn_c]$ ./a.out goodno[taoge@localhost learn_c]$ ./a.out Good123yes[taoge@localhost learn_c]$ ./a.out Goodyes[taoge@localhost learn_c]$
我们可以看到, 这些测试用例是手动的。 手动测试用例的缺点是:
1. 手动测试用例不便于保存(假设一个月后, 要再测一遍, 还得再敲一次。 当然, 你可能说, 你会保存这些文本, 但那样也需要复制命令到shell中重新运行)
2. 手动测试用例很麻烦, 稍微不注意就会出错,没有一气呵成的感觉, 不利于自动化测试。
对了, 前面不是一直在说脚本脚本么, 现在用脚本来搞一下自动化测试用例:
#!/bin/sh$1echo ""x=goodecho "$x"$1 "$x"x=goodbyeecho "$x"$1 "$x"x=Goodecho "$x"$1 "$x"x=Goodbyeecho "$x"$1 "$x"x="Good bye"echo "$x"$1 "$x"
结果为:
[taoge@localhost learn_c]$ lsa.out test.c test.sh[taoge@localhost learn_c]$ ./test.sh ./a.out para errorgoodnogoodbyenoGoodyesGoodbyeyesGood byeyes[taoge@localhost learn_c]$
自动化, 真是好啊, 一劳永逸。
0 0
- 利用linux shell script来测试linux c程序------脚本自动化测试用例代替手动测试用例
- 利用linux shell script来测试linux c程序------脚本自动化测试用例代替手动测试用例
- 用Expect来做Linux程序测试
- Python自动化测试--一个简单的自动化测试脚本--批量执行测试用例
- shell script 自动化测试框架 - shUnit2
- 手动测试VS自动化测试
- linux shell脚本编程之测试判断
- linux 性能测试监控shell脚本
- 自动化测试:自动化测试用例设计实例
- 自动化测试用例操作
- Android自动化测试shell脚本(飞车Asphalt5)
- 使用shell脚本实现android自动化测试
- Android自动化测试shell脚本(飞车Asphalt5)
- linux shell 测试条件
- linux shell 条件测试
- linux shell测试网速
- linux-shell 测试
- linux上传测试脚本
- 第三章第45题累加
- 应该知道的Linux技巧
- 人工智能基本知识体系
- copy, retain, assign 使用情景
- C/C++中static的区别
- 利用linux shell script来测试linux c程序------脚本自动化测试用例代替手动测试用例
- ubuntu下matlab快捷键问题 shortcuts
- Windows系统桌面生成非快捷方式的IE图标
- java 微信开发,各种接口调用,精心收集
- css写三角兼容ie6
- GCC 编译报错:程序中有游离的 \357’ \273’ \277’ 等
- 玩转CSDN之自定义博客栏目
- 什么是堆和栈,它们在哪儿?
- 黑马程序员---(学习日志——多线程)Java中多线程