嵌入式测试大赛实例解析
明天就是嵌入式大賽的預(yù)選賽了,今晚加班寫個(gè)博客
1、安裝環(huán)境
下載了官方的安裝包之后,官方給出了詳細(xì)的安裝說明,下載請(qǐng)看百度網(wǎng)盤地址:
鏈接:https://pan.baidu.com/s/1ngYQK3c2P1e367SFC3Q__A 密碼:dwud
1.1、首先安裝VSDP,具體的文件名為:
vspdxp_install.exe1.2、配置虛擬串口
運(yùn)行
在彈出來的軟件頁面中選擇
COM5 COM6這兩個(gè)串口
1.3、安裝ETest軟件
1.4、運(yùn)行Etest軟件-進(jìn)程調(diào)度服務(wù)
1.5、運(yùn)行測(cè)試設(shè)計(jì)臺(tái)
1.6、打開給定的測(cè)試項(xiàng)目文件
1.7、在“設(shè)備規(guī)劃”上點(diǎn)擊右鍵,選擇“編輯”,打開設(shè)備規(guī)劃
1.8、.選中“物理通道”下面的“232”,打開“屬性”標(biāo)簽頁,選擇“端口名”為一對(duì)虛擬串口
中的一個(gè)
1.9、運(yùn)行被測(cè)軟件,啟動(dòng)服務(wù),選擇端口號(hào)
1.10、打開測(cè)試項(xiàng)目中的測(cè)試“功能 2”
1.11、首先進(jìn)行“環(huán)境設(shè)置”
1.12、點(diǎn)擊“運(yùn)行”
1.13、使用對(duì)話框判斷測(cè)試結(jié)果
1.14、查看界面輸出結(jié)果
2、例題一
題目分享:鏈接:https://pan.baidu.com/s/1uPS_y3bo_OLRc0FFZqpvkw 密碼:rsjg
題目由一個(gè)需求文檔和測(cè)試要求給出,這是關(guān)于模擬水流監(jiān)控計(jì)費(fèi)器的題目
2.1、定義協(xié)議:
如仿真圖所示,這里定義了Protocol_1和Protocol_2以及CH_232_1三種自定義通信類型。具體的實(shí)現(xiàn)如下
//協(xié)議Protocol_1 Protocol MainSegment 包頭 StandardUInt16 Default=0X55AA ByteOrder=BigSegment 閥門控制器ID StandardUInt8 Default=0Segment 水流監(jiān)控計(jì)費(fèi)器ID StandardUInt8 Default=0X20Segment 瞬時(shí)流量 StandardFloat Default=0.0Segment 計(jì)費(fèi)標(biāo)志 StandardUInt8 Default=0Segment 管道壓力 StandardFloat Default=0.0Segment 校驗(yàn)和 CRC Algorithm=CRC_SUM_8 BitCount=16 Range=(16,0) Segment 包尾 StandardUInt16 Default=0X55AA ByteOrder=Big End//協(xié)議Protocol_2 Protocol MainSegment 包頭 StandardUInt16 Default=0X55AA ByteOrder=BigSegment 水流監(jiān)控計(jì)費(fèi)器ID StandardUInt8 Default=0X20Segment 閥門控制器ID StandardUInt8 Default=0Segment 瞬時(shí)流量報(bào)警標(biāo)志 StandardUInt8 Default=0Segment 管道壓力控制指令 StandardUInt8 Default=0Segment 校驗(yàn)和 CRC Algorithm=CRC_SUM_8 BitCount=8 Range=(16,0)Segment 包尾 StandardUInt16 Default=0X55AA ByteOrder=Big End//協(xié)議CH_232_1似乎是系統(tǒng)定義的遇到了一個(gè)報(bào)錯(cuò)
提示我協(xié)議沒有定義,但是實(shí)際上協(xié)議是定義了的,只不過這兩個(gè)東西沒有嵌入起來
3、例題二
題目分享:鏈接:https://pan.baidu.com/s/1P16uKgLtrLjIl1o5Jo9y1Q 密碼:nmbs
模擬共享單車
這道題是去年秋季賽的分區(qū)預(yù)賽題目
按照以上的操作,打開待測(cè)元器件的服務(wù)端(也就是.exe結(jié)尾的應(yīng)用程序),然后打開功能3的測(cè)試
測(cè)試代碼示例:
import Manu ############標(biāo)準(zhǔn)測(cè)試模板####################### ## Test:測(cè)試數(shù)據(jù)執(zhí)行函數(shù)體,【測(cè)試數(shù)據(jù)】每一行數(shù)據(jù)調(diào)用一次Test ## arg:輸入?yún)?shù) ## exp:預(yù)期輸出 def Test(arg,exp):print 'Hello World!'for a in arg:print afor e in exp:print eProtocol_gpstime.Hour.Value=arg[0]Protocol_gpstime.Minute.Value=arg[1]Protocol_gpstime.Second.Value=arg[2]Protocol_gpstime.JingDu.Value=arg[3]Protocol_gpstime.Flag_JD.Value=arg[4]Protocol_gpstime.WeiDu.Value=arg[5]Protocol_gpstime.Flag_WD.Value=arg[6]Protocol_gpstime.Write()show=[]str='輸入數(shù)據(jù):時(shí)%d,分%d,秒%d,經(jīng)度%f,經(jīng)度標(biāo)識(shí)%d,緯度%f,緯度標(biāo)識(shí)%d\n' %(arg[0],arg[1],arg[2],arg[3],arg[4],arg[5],arg[6])show.append(str)show.append(exp[0])passed=Manu.Check(show)print '測(cè)試結(jié)果:%s' %passed# 斷言:根據(jù)實(shí)際需求修改一下注釋的部分 assertor=API.Platform.Assertion.Create()assertor.AddInput('時(shí)',arg[0])assertor.AddInput('分',arg[1])assertor.AddInput('秒',arg[2])assertor.AddInput('經(jīng)度',arg[3])assertor.AddInput('經(jīng)度標(biāo)識(shí)',arg[4])assertor.AddInput('緯度',arg[5])assertor.AddInput('緯度標(biāo)識(shí)',arg[6])assertor.AddOutput('界面顯示',exp[0],passed)if passed:#測(cè)試通過assertor.Pass()else:assertor.Failed()b=assertor.Commit()## Standard_Test:標(biāo)準(zhǔn)測(cè)試的方法入口,使用【測(cè)試數(shù)據(jù)】表循環(huán)調(diào)用Test方法 Standard_Test(Test) #########################################################自定義測(cè)試模板####################### ## 如果不希望使用測(cè)試數(shù)據(jù)驅(qū)動(dòng)測(cè)試,則將【標(biāo)準(zhǔn)測(cè)試模板】刪除,使用【自定義模板】 ## 否則可以刪除本節(jié) #def Main(): # print 'Hello world' #Main() #################################################測(cè)試結(jié)果既可以通過應(yīng)用程序查看
也可以通過日志文件進(jìn)行查看
再來看一個(gè)接口測(cè)試的示例
接口4的需求為:
為了清除剛才的環(huán)境,可以點(diǎn)擊清除環(huán)境設(shè)置,然后點(diǎn)開接口4的測(cè)試,自己寫上測(cè)試代碼,點(diǎn)擊清理環(huán)境。
這是例題給的測(cè)試代碼:
運(yùn)行結(jié)果為
性能測(cè)試示例:
需求:
示例代碼:
import time t1=time.time() def Test(arg,exp):global t1print 'Hello World!'t2=time.time()while True:bool=Protocol_ServerOutput.Read()t2=time.time()if bool:breakprint 'GPS上報(bào)時(shí)間間隔為:%.2f秒' %(t2-t1)passed=Falseif int(t2-t1)>=6 and int(t2-t1)<=10:passed=True## 斷言:根據(jù)實(shí)際需求修改一下注釋的部分 assertor=API.Platform.Assertion.Create()assertor.AddOutput('輸出參數(shù)1',exp[0],str(t2-t1))if passed:#測(cè)試通過assertor.Pass()else:assertor.Failed()t1=t2b=assertor.Commit()## Standard_Test:標(biāo)準(zhǔn)測(cè)試的方法入口,使用【測(cè)試數(shù)據(jù)】表循環(huán)調(diào)用Test方法 Standard_Test(Test) #############################################測(cè)試結(jié)果:
4、例題三
題目分享:鏈接:https://pan.baidu.com/s/1OmASWyIFUvYCzqtJX8SFJA 密碼:n06t
模擬空調(diào)
2017年嵌入式測(cè)試分區(qū)決賽題目
注意:
4.1、溫度測(cè)試
import Manu ############標(biāo)準(zhǔn)測(cè)試模板####################### ## Test:測(cè)試數(shù)據(jù)執(zhí)行函數(shù)體,【測(cè)試數(shù)據(jù)】每一行數(shù)據(jù)調(diào)用一次Test ## arg:輸入?yún)?shù) ## exp:預(yù)期輸出 def Test(arg,exp):print '測(cè)試用例%d:命令設(shè)定溫度值為%d' % (arg[1],arg[0])Protocol_1.Tmp.Value=arg[0]Protocol_1.Write()API.Common.Timer.Normal.Sleep(1000)show=[]str = '遙控器設(shè)定溫度為:%d,界面預(yù)期顯示為:%d' % (arg[0],exp[0])show.append(str)show.append('界面室溫顯示是否正確?')passed=Manu.Check(show)if(passed):print '界面顯示與預(yù)期一致,界面判斷通過'else:print '界面顯示與預(yù)期不一致,界面判斷不通過'## 斷言:根據(jù)實(shí)際需求修改一下注釋的部分 assertor=API.Platform.Assertion.Create()assertor.AddInput('命令設(shè)置溫度',arg[0])assertor.AddOutput('界面顯示溫度',exp[0],passed)if (arg[0]<16 and exp[0]==16 and passed) or (arg[0]>30 and exp[0]==30 and passed) or (16<=arg[0]<=30 and exp[0]==arg[0] and passed) :#測(cè)試通過print '本次測(cè)試通過。'assertor.Pass()else:print '本次測(cè)試不通過,請(qǐng)輸入測(cè)試問題'assertor.Failed()b=assertor.Commit()## Standard_Test:標(biāo)準(zhǔn)測(cè)試的方法入口,使用【測(cè)試數(shù)據(jù)】表循環(huán)調(diào)用Test方法 Standard_Test(Test)每次重新進(jìn)行測(cè)試時(shí)最好清理環(huán)境,避免因上一個(gè)測(cè)試用例的結(jié)果影響到接下來的測(cè)試
總結(jié)
以上是生活随笔為你收集整理的嵌入式测试大赛实例解析的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mysql进销存表设计_企业采购进销存管
- 下一篇: 猎豹移动2016研发工程师笔试题