先来看看项目结构
ttcn代码如下:
module Codec_A { //1.端口定义 type port common_port message { inout all } //2.成分定义 type component MyMTC{ port common_port mtc_port; } type component MySUT{ port common_port sut_port; } // 定义测试例 testcase Basic_TC () runs on MyMTC system MySUT { mtc_port.clear; //不能操作sut_port,这个端口在SUT,并不在MTC的控制下 //sut_port.clear; map(mtc:mtc_port, system:sut_port); mtc_port.start; //不能操作sut_port,这个端口在SUT,并不在MTC的控制下 //sut_port.start; mtc_port.send('ABCD'O); mtc_port.receive('ABCD'O) setverdict(pass); stop; } //控制部分 control { execute(Basic_TC()); } } // Module Codec_A end |
在这个例子里面,mtc通过端口发送‘ABCD’,然后检测自己是否接收到了‘ABCD’,然后判断测试例通过。