|
偶用等价类分析法尝试测试 Javac
这里好像不能上传附件. 偶用Java写的源代码文件传不上来,怎么办昵?
[目标]:
1. 学习java
2. 学习等价类分析法,了解等价类分析法在具体测试中可能碰到的问题
3. 测试诀窍.
[前置条件]
1. J2SE6 JavaC规范
2. 安装Java虚拟机(JVM )SE 6.0
3. 源代码: http://www.51testing.com/attachments/2007/12/2054_200712201651221.attach
[步骤]
1. 确定等价类
阅读 J2SE6 JavaC规范,并掌握其中的Feature.
1.1 生成基本的等价类
外部条件 有效等价类 无效等价类
Order of arguments (1) The combination of the orders
Number of source files (2) one, (3)more (4) 0 source file
Src file suffix (5) .java (6) Other types
Number of Arg files (7) one, (8)more (9) 0 Arg files
Content of arg files (10) Options, (11) Src files (12), Both (13) Other
Type of definition (14) Class (15) Interface (16) Other type
Language of source file (17) Java language (18) Other language
Ways to pass src files (19) Command line (20)In Arg file (21) Both in command line and arg file
Arg file symbol is @ (22) Yes (23) No
Src file name=class name (24) Yes (25) No
Dir tree reflect package tree (26) Yes (27) No
Output DIR (28) same as src dir, (29)Seperate dir
Is class path Specified (30) Yes (31) No
-d Is Dir exists (31) Yes (32)No
-d Is class part of package (33) Yes (34) No
-d Sub dir of dest Dir (35) 0, (36) 1, (37) more
-d Number of dest Dirs (38) 1 (39) more
1.2 精化等价类 消除/确定等价类间依赖
Order of arguments The combination of the orders
Src file suffix .java Other types
Ways to pass src files Command line, Arg file, Both
Src files in command line (one, Zero), (one, one), (one, more), (Zero, Zero)
and arg files combine (more, zero), (more, one), (more, more)
(Zero, one), (Zero, more)
Content of arg files None, Options, Src files, Both Other
Type of definition Class, Interface Other type
Language of source file Java language Other language
Arg file symbol is @? Yes No
Src file name=class name Yes No
Package & Dir tree relation
Has Package: Yes, No
Dir reflect package: Yes, No (Yes, Yes), (Yes,No), (No, Yes), (No, No)
Output Dir same as src dir, Seperate dir
-d Is Dir exists Yes No
-d Is class part of package Yes No
-d Sub dir of dest Dir 0, 1, more
-d Number of dest Dirs 1 more
1.3 精化-确定 项间关系
Order of arguments (1) The combination of the orders[Order1, Order2]
order1 1A: Option, Source File, Arg File
order2 1B: Arg File, Option, Source File
Src file suffix (2) .java (3) Other types
Ways to pass src files (4)(more, zero) (5)(more, more) (7)(Zero, Zero)
Command line,Arg file,Both (6)(Zero, more)
Arg file symbol is @? (8) Yes (9) No
Content of Arg files (10)None (11)Src files (14)Other
(12)Options (13)Both
Type of definition (15)Class (16)Interface or Both (17) Other type
Language of source file (18)Java language (19) Other language
Src file name=class name (20)Yes (21) No
Has Package: (22)Yes (23)No
Output Dir (24)Src dir (25)Seperate dir
-d Is Dir exists (26)Yes (27)No
-d Dest Dir contains Sub Dir (28)0 (29)1 (30)more
-d Number of dest Dirs (31)1, (32)More
2. 生成测试用例
1. 为每个等价类设置不同的编号.
2. 编写新的测试用例,尽可能多滴覆盖那些尚未被覆盖的有效等价类,直到所有的有效等价类都被测试用例所覆盖.
3. 编写新的测试用例,覆盖一个且仅一个尚未被覆盖的无效等价类,直到所有的无效等价类都被测试用例所覆盖.
Valid EP
1) 1A,2,4,10,15,18,20,22,24
javac hello.java hello2.java
2) 1A,2,5,8,11,16,18,20,23,25,26,28,31
javac hello.java, hello1.java @argSrc
3) 1B,2,6,8,12,16,18,20,23,25,26,29,31
javac @argSrc -g hello1.java
4) 1B,2,6,8,13,16,18,20,23,25,26,30,31
invalid EP
5) 3
6) 7
7) 9
7) 14
9) 17
10) 19
11) 21
12) 28
13) 33
[经验总结]
1. 等价类分析法适合在测试某个功能点的时候采用, 譬如说要测试Javac的 -d 选项的功能。
如果要测试整个Javac命令,则不是很合适,因为项间的依赖关系很多,譬如说 支持参数文件 和 指定源代码文件的 方式就不能只是 通过命令行传参数
2. 等价项之间的依赖关系多会导致组合爆炸
3. 覆盖率不是很够。
4. 缺乏做等价类分析的工具. 譬如说,在精化等价类的过程中,经常发现原来的想法不全面,需要加入新的等价类,加入后,需要手工把所有的编号更新一边,如果有这样的工具就好了。 |
|