在 Fitnesse 中获取 !today 变量的子字符串

发布于 10-21 14:08 字数 359 浏览 3 评论 0原文

我正在为网络应用程序编写 Fitnesse 测试。要测试的项目之一是下拉框,其值由当前日期确定,格式为 DD/MM/YYYY。

我原以为在 Fitnesse 套件中使用 !today 变量可能是设置变量的有用方法,但我遇到了 Fitnesse 将日期表示为(例如)2011 年 3 月 11 日< /em>,我需要11/03/2011。我可以使用 -xml 修饰符获取数字格式的日期,但仍然留下一个相当大的字符串,例如 2011-03-11T05:51:22

有没有办法获取它的子字符串,然后将它们通过管道传输到页面变量中,或者我在这里吠叫完全错误的树?

谢谢!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

蓝海似她心2024-10-28 14:08:27

!today (MM/dd/yyyy) 生成 09/17/2012。您可以使用任何您喜欢的格式代码。它使用 SimpleDateFormat 类。

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

双马尾2024-10-28 14:08:27

好吧,事实证明这棵树并不完全错误:-)

作为参考,!today 函数还有一些其他方法,您可以根据需要使用它们来收集日期的各个部分:

!today (dd) - 以数字形式给出该月的第几天
!today (MM) - 以数字形式给出一年中的月份
!today (yyyy) - 以数字形式给出年份

还有其他一些,但我最终只使用了这些。根据需要将它们组合起来,罗伯特就是你母亲的兄弟,可以说……

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...

失而复得2024-10-28 14:08:27

这将为您提供在 Fitnesse Wiki 中编写的测试用例中所需的日期

${=!today (ddMMyyyy)=}

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

${=!today (ddMMyyyy)=}

滥情空心2024-10-28 14:08:27

这 ! (感叹号)按字面解释,因此像 !today 这样的符号不会扩展。您可以使用普通表:

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

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)|
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文