XQuery,断言日期格式而不是实际日期?
我有一些肥皂 UI 测试,其中包含对其收到的响应的 XQuery 断言,如下所示:
declare namespace soapenv='http://schemas.xmlsoap.org/soap/envelope/';
declare namespace ns2='http://mydomain.com/mydata_1';
/soapenv:Envelope/soapenv:Body/ns2:itemDetail/ns2:startDate
目前,我使用以下预期结果:
<ns2:startDate>2008-01-01T00:00:00.000Z</ns2:startDate>
目前效果很好,但该数据可能会更改。
问题:有没有办法可以断言日期的格式,例如,我不关心返回的日期值是否与特定格式匹配?
我可以使用:
<ns2:startDate>*</ns2:startDate>
但是我可以得到任何日期格式
有这样的东西吗?
<ns2:startDate>yyyy-MM-dd HH:mm:ss.ms</ns2:startDate>
谢谢
I've got some soap UI tests, that contain XQuery assertions on the responses it receives, such as the following :
declare namespace soapenv='http://schemas.xmlsoap.org/soap/envelope/';
declare namespace ns2='http://mydomain.com/mydata_1';
/soapenv:Envelope/soapenv:Body/ns2:itemDetail/ns2:startDate
Currently, I use the following expected result :
<ns2:startDate>2008-01-01T00:00:00.000Z</ns2:startDate>
This works fine, for now, however that piece of data can change.
Question : Is there a way I can assert on the format of the date, for example I don't care what date value I get back providing it matches a particular format?
I could use :
<ns2:startDate>*</ns2:startDate>
But then I could get any date format
Is there something like this?
<ns2:startDate>yyyy-MM-dd HH:mm:ss.ms</ns2:startDate>
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将查询编写为
/soapenv:Envelope/soapenv:Body/ns2:itemDetail/ns2:startDate/matches(., $regex)
,预期结果为 true,其中 $regex 是您期望数据的正则表达式匹配。
You could write your query as
/soapenv:Envelope/soapenv:Body/ns2:itemDetail/ns2:startDate/matches(., $regex)
with an expected result of true, where $regex is a regular expression that you expect the data to match.