欢迎来到天天文库
浏览记录
ID:15006565
大小:706.50 KB
页数:15页
时间:2018-07-31
《tcl集成测试环境搭建指南(console版)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、Tcl集成测试环境搭建指南修订记录第一步:获取tcl8.3的安装包,安装到c:目录下(安装时一定要选取lib库安装)。第二步:利用VisualC++建立一个Win32ConsoleApplication工程,工程的名字为CounterTest。因为被测对象有MFC类,所以该工程应该支持MFC:第三步:参照下面两个图,分别创建test.h和test.cpp文件。这两个文件均为空文件。第四步:添加被测试模块的代码1)把下面的代码拷贝到文件test.cpp中:2)把下面的代码拷贝到文件test.h中第五步:添加tcl扩展指令代码1)把下面的代码拷贝到文件CounterTest.cpp中:#incl
2、ude"stdafx.h"#include"CounterTest.h"#include"tcl.h"#include"test.h"intTclEx_Counter(ClientDataclientData,Tcl_Interp*interp,intargc,char*argv[]){returnTCL_OK;}第六步:1)定义tcl解释器:通过使用TCL内部的数据类型Tcl_Interp定义TCL解释器全局变量。在文件CounterTest.cpp中定义tcl解释器,即全局变量:Tcl_Interp*MyInterp;例如:(红色部分为添加的代码)//定义解释器Tcl_Interp*MyI
3、nterp;2)创建解释器:通过使用TCL函数Tcl_CreateInterp()创建解释器。(并且返回解释器首地址)在文件CounterTest.cpp中创建tcl解释器,例如:(红色部分代码)int_tmain(intargc,TCHAR*argv[],TCHAR*envp[]){intnRetCode=0;//initializeMFCandprintanderroronfailureif(!AfxWinInit(::GetModuleHandle(NULL),NULL,::GetCommandLine(),0)){//TODO:changeerrorcodetosuityourneed
4、scerr<<_T("FatalError:MFCinitializationfailed")<5、ounter,NULL,NULL);intrCode;charsScript[255];//CStringsScript;while(1){//通过嵌入集成测试框架的Tcl解释器MyInterp,运行外部传入的tcl脚本printf("请输入要执行的TCL脚本文件名:");scanf("%s",&sScript);rCode=Tcl_EvalFile(MyInterp,(char*)sScript);if(TCL_OK!=rCode){printf("ThereareerrorsinyourTclFile");}else{printf("TestingSucceed!");}//C6、StringstrHello;//strHello.LoadString(IDS_HELLO);//cout<<(LPCTSTR)strHello<7、ndle(NULL),NULL,::GetCommandLine(),0)){//TODO:changeerrorcodetosuityourneedscerr<<_T("FatalError:MFCinitializationfailed")<
5、ounter,NULL,NULL);intrCode;charsScript[255];//CStringsScript;while(1){//通过嵌入集成测试框架的Tcl解释器MyInterp,运行外部传入的tcl脚本printf("请输入要执行的TCL脚本文件名:");scanf("%s",&sScript);rCode=Tcl_EvalFile(MyInterp,(char*)sScript);if(TCL_OK!=rCode){printf("ThereareerrorsinyourTclFile");}else{printf("TestingSucceed!");}//C
6、StringstrHello;//strHello.LoadString(IDS_HELLO);//cout<<(LPCTSTR)strHello<7、ndle(NULL),NULL,::GetCommandLine(),0)){//TODO:changeerrorcodetosuityourneedscerr<<_T("FatalError:MFCinitializationfailed")<
7、ndle(NULL),NULL,::GetCommandLine(),0)){//TODO:changeerrorcodetosuityourneedscerr<<_T("FatalError:MFCinitializationfailed")<
此文档下载收益归作者所有