随笔-60  评论-98  文章-0  trackbacks-0
应用程序的接口不外乎三种,CLI——命令行接口,API——应用编程接口和GUI。

因为现在有大把集成快速开发功能的IDE可供选择,因此GUI的实现变得非常的顺手。工具水平提高了,这看起来是理所当然的事情。其实呢?

单一的GUI接口,带来实现上的便利,用户只和GUI打交道,他们也没话说,那测试人员呢?有没有换位思考过,各位DEV们?

GUI有一个特点就是不稳定,元素的增减,是否显示,显示的位置,控件更新,都会引起GUI的变化,随之引发了自动化脚本失效,这是个很让人挠头的问题,冒烟测试停住了,回归也要大量人工介入。

需要提供更丰富的接口,CLI是一种不错的选择,因为CLI不但可以用在单元测试,更可以用到系统测试阶段,前提是整个软件要提供相当的CLI接口,让交互可以自动化起来。

看一个Xerces参数处理的例子

中间有一个usage(),输出使用帮助到屏幕

 1    int argInd;
 2    for (argInd = 1; argInd < argC; argInd++)
 3    {
 4        // Break out on first parm not starting with a dash
 5        if (argV[argInd][0!= '-')
 6            break;
 7
 8        // Watch for special case help request
 9        if (!strcmp(argV[argInd], "-?"))
10        {
11            usage();
12            return 2;
13        }

14         else if (!strncmp(argV[argInd], "-v="3)
15              ||  !strncmp(argV[argInd], "-V="3))
16        {
17            const char* const parm = &argV[argInd][3];
18
19            if (!strcmp(parm, "never"))
20                valScheme = AbstractDOMParser::Val_Never;
21            else if (!strcmp(parm, "auto"))
22                valScheme = AbstractDOMParser::Val_Auto;
23            else if (!strcmp(parm, "always"))
24                valScheme = AbstractDOMParser::Val_Always;
25            else
26            {
27                XERCES_STD_QUALIFIER cerr << "Unknown -v= value: " << parm << XERCES_STD_QUALIFIER endl;
28                return 2;
29            }

30        }

31         else if (!strcmp(argV[argInd], "-n")
32              ||  !strcmp(argV[argInd], "-N"))
33        {
34            doNamespaces = true;
35        }

36         else if (!strcmp(argV[argInd], "-s")
37              ||  !strcmp(argV[argInd], "-S"))
38        {
39            doSchema = true;
40        }

41         else if (!strcmp(argV[argInd], "-f")
42              ||  !strcmp(argV[argInd], "-F"))
43        {
44            schemaFullChecking = true;
45        }

46         else if (!strcmp(argV[argInd], "-l")
47              ||  !strcmp(argV[argInd], "-L"))
48        {
49            doList = true;
50        }

51         else if (!strcmp(argV[argInd], "-special:nel"))
52        {
53            // turning this on will lead to non-standard compliance behaviour
54            // it will recognize the unicode character 0x85 as new line character
55            // instead of regular character as specified in XML 1.0
56            // do not turn this on unless really necessary
57
58             recognizeNEL = true;
59        }

60         else if (!strcmp(argV[argInd], "-p")
61              ||  !strcmp(argV[argInd], "-P"))
62        {
63            printOutEncounteredEles = true;
64        }

65         else if (!strncmp(argV[argInd], "-locale="8))
66        {
67             // Get out the end of line
68             strcpy(localeStr, &(argV[argInd][8]));
69        }
            
70         else
71        {
72            XERCES_STD_QUALIFIER cerr << "Unknown option '" << argV[argInd]
73                 << "', ignoring it\n" << XERCES_STD_QUALIFIER endl;
74        }

75    }

76
77    //
78    //  There should be only one and only one parameter left, and that
79    //  should be the file name.
80    //
81    if (argInd != argC - 1)
82    {
83        usage();
84        return 1;
85    }
posted on 2009-05-20 10:12 创建更好的解决方案 阅读(1402) 评论(0)  编辑 收藏 引用 所属分类: TDDC++专栏软件测试软件设计

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理