适用于:主要样本和子样本 要测试的响应字段:文本响应 模式匹配规则:包含
要测试的模式:
<?xml version="1.0" encoding="ISO-8859-5" standalone="yes"?>
<CIT_REQUEST>
<SYSTEM>
<CIT_Version Value="1.0"/>
<ERR Value=""/>
<FORMAT Value="XML"/>
<INTERFACE_RET Value=""/>
<MAIN_ID Value="37407427745"/>
<MSG_ID Value=".*"/> - regexp not working
<SYNC Value="N"/>
<Version Value="002"/>
</SYSTEM>
<DATA>
<PACKAGE_B64>
PE1zZ0NsaWVudEFkZFJzIHhtbG5zPSJ1cm46c2NoZW1hcy1wc2l0LXJ1OmdwIj48
UnFVSUQ+Mzc0MDc0Mjc3NDU8L1JxVUlEPjxScVJlc3VsdD48U3RhdHVzPk9rPC9T
dGF0dXM+PENvbW1lbnQ+TmV3PC9Db21tZW50PgoJCQk8L1JxUmVzdWx0PjxSZXN1
bHQ+PENsaWVudElkPjc3MzY0NTgyPC9DbGllbnRJZD48SW50ZXJuYWxfQ2xpZW50
SWQ+MjY3PC9JbnRlcm5hbF9DbGllbnRJZD4KCQkJPC9SZXN1bHQ+CgkJPC9Nc2dD
bGllbnRBZGRScz4=
</PACKAGE_B64>
</DATA>
</CIT_REQUEST>
响应:
<?xml version="1.0" encoding="ISO-8859-5" standalone="yes"?>
<CIT_REQUEST>
<SYSTEM>
<CIT_Version Value="1.0"/>
<ERR Value=""/>
<FORMAT Value="XML"/>
<INTERFACE_RET Value=""/>
<MAIN_ID Value="37407427745"/>
<MSG_ID Value="F3C826680F5E45C3AA97DEE4DA51F54B"/> - MSG_ID Value changes for each request
<SYNC Value="N"/>
<Version Value="002"/>
</SYSTEM>
<DATA>
<PACKAGE_B64>
PE1zZ0NsaWVudEFkZFJzIHhtbG5zPSJ1cm46c2NoZW1hcy1wc2l0LXJ1OmdwIj48
UnFVSUQ+Mzc0MDc0Mjc3NDU8L1JxVUlEPjxScVJlc3VsdD48U3RhdHVzPk9rPC9T
dGF0dXM+PENvbW1lbnQ+TmV3PC9Db21tZW50PgoJCQk8L1JxUmVzdWx0PjxSZXN1
bHQ+PENsaWVudElkPjc3MzY0NTgyPC9DbGllbnRJZD48SW50ZXJuYWxfQ2xpZW50
SWQ+MjY3PC9JbnRlcm5hbF9DbGllbnRJZD4KCQkJPC9SZXN1bHQ+CgkJPC9Nc2dD
bGllbnRBZGRScz4=
</PACKAGE_B64>
</DATA>
</CIT_REQUEST>
断言失败消息:
Assertion error: false
Assertion failure: true
Assertion failure message: Test failed: text expected to contain /<?xml version="1.0" encoding="ISO-8859-5" standalone="yes"?>
<CIT_REQUEST>
<SYSTEM>
<CIT_Version Value="1.0"/>
<ERR Value=""/>
<FORMAT Value="XML"/>
<INTERFACE_RET Value=""/>
<MAIN_ID Value="37407427745"/>
<MSG_ID Value=".*"/>
<SYNC Value="N"/>
<Version Value="002"/>
</SYSTEM>
<DATA>
<PACKAGE_B64>
PE1zZ0NsaWVudEFkZFJzIHhtbG5zPSJ1cm46c2NoZW1hcy1wc2l0LXJ1OmdwIj48
UnFVSUQ+Mzc0MDc0Mjc3NDU8L1JxVUlEPjxScVJlc3VsdD48U3RhdHVzPk9rPC9T
dGF0dXM+PENvbW1lbnQ+TmV3PC9Db21tZW50PgoJCQk8L1JxUmVzdWx0PjxSZXN1
bHQ+PENsaWVudElkPjc3MzY0NTgyPC9DbGllbnRJZD48SW50ZXJuYWxfQ2xpZW50
SWQ+MjY3PC9JbnRlcm5hbF9DbGllbnRJZD4KCQkJPC9SZXN1bHQ+CgkJPC9Nc2dD
bGllbnRBZGRScz4=
</PACKAGE_B64>
</DATA>
</CIT_REQUEST>/
请帮助regexp或其他方法。
答案 0 :(得分:1)
根据How to Use JMeter Assertions in Three Easy Steps文章
的“回应断言”章节模式可以是:
- “等于”或“子串”子句的“字符串”
- “包含”或“匹配”子句的“Perl5风格”正则表达式
醇>
所以你有两个选择:
如果您仍想使用“包含”模式匹配规则need to escape:
.^$*+?()[{\|
字符^-]\
个字符更简单的选项是将模式匹配规则更改为“等于”或“子串”
答案 1 :(得分:0)
答案 2 :(得分:0)
对于XML断言最好的方法是使用jmeter提供的XML断言,这将检查XML的整个语法