开发者

Getting substrings of the !today variable in Fitnesse

I'm writing a Fitnesse test for a web application. One of the items to test is a drop-down box, whose value is determined by the current date, in DD/MM/YYYY format.

I'd thought that using the !today variable in the Fitnesse suite might be a useful way of setting a variable, but I've run into the problem that开发者_开发知识库 Fitnesse expresses the date as (for example) 11 Mar, 2011, where I need 11/03/2011. I can get the date in numberic format using the -xml modifier, but I'm still left with a pretty huge string like 2011-03-11T05:51:22.

Is there a way of getting substrings of this, and then piping those into page variables, or am I barking up entirely the wrong tree here?

Thanks!


!today (MM/dd/yyyy) produces 09/17/2012. You can use any format codes you like. It uses the SimpleDateFormat class.


Well, it turns out not entirely the wrong tree :-)

For reference, the !today function has a few other methods, and you can use them to gather individual sections of the date as necessary:

!today (dd) - gives the day of the month, in numeric form !today (MM) - gives the month of the year, in numeric form !today (yyyy) - gives the year, in numeric form

There are a few others, but all I ended up using were these. Combine them as necessary, and Robert is your mother's brother, as it were...


This will get you the date you require in Test Cases written in Fitnesse Wiki

${=!today (ddMMyyyy)=}


The ! (Exclamation mark) is interpreted literally, so symbols like !today are not expanded. You can use a plain table:

|class name|
|!today (MM/dd/yyyy)|
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜