开发者

XQuery, assert on format of date rather than actual date?

开发者 https://www.devze.com 2023-03-12 05:14 出处:网络
I\'ve got some soap UI tests, that contain XQuery assertions on the responses it receives, such as the following :

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开发者_StackOverflow 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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号