简体   繁体   English

Java Cucumber 通过 function 到步进 ZDBC11CAA5BDA99F77E6FB4DABD882E7D

[英]Java Cucumber passing function to step arguments

I have step: Then date in field: is equal to 'myDate'我有步骤:然后字段中的日期:等于'myDate'

usually data-time format data is transferred to this step but I have a specific case that checks that the date is today, so I cannot hardcode the date通常将数据时间格式数据传输到此步骤,但我有一个特定情况可以检查日期是否为今天,因此我无法对日期进行硬编码

How I can resolve this prombel.我该如何解决这个问题。 Please help.请帮忙。

Better way in such case is to handle it inside step.在这种情况下,更好的方法是在步骤内处理它。 For instance,例如,

Then date in field: is equal to today

However, If you are using cucumber version 5+ you can use qaf-cucumber that will enable features from qaf which allows you to use properties .但是,如果您使用的是 cucumber 版本 5+,您可以使用qaf-cucumber来启用 qaf 的功能,从而允许您使用properties

Below is example.下面是例子。

Then date in field: is equal to '${expr:com.qmetry.qaf.automation.util.DateUtil.getDate(0, 'MM/dd/yyyy')}'

Alternately you can have property that store value for today and use that property.或者,您可以拥有为今天存储价值的财产并使用该财产。 For example: in property file例如:在属性文件中

today = ${expr:com.qmetry.qaf.automation.util.DateUtil.getDate(0, 'MM/dd/yyyy')}

your step:你的步骤:

Then date in field: is equal to '${today}'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM