ReadyAPI - Data Source - Minimum value as today´s date - Possible?
Hi everyone! I am trying to generate a list of dates to be used in a test case step in my ReadyAPI project. My idea is to have a list of 14 dates to be generated by the Data Source step, starting from today´s date and incrementing the date value by 1 day for each subsequent date to be generated.
This is how the setup looks like for now, generating the list of dates from today for the next 14 days.
The issue as you might understand if that I cannot dynamically set the start date as today´s date, but manually set it myself when I run the test. Is there a way around it via Data Source --> Data Generator --> Date and Time?
I have also tried to have a Groovy Script instead of a Data Generator (so Data Source --> Groovy Script), but I am having troubles with the outcome. This is how it looks like right now:
import java.text.SimpleDateFormat
import java.util.Calendar
// Get the current date
def currentDate = Calendar.getInstance()
def dateFormat = new SimpleDateFormat("yyyy-MM-dd")
// Calculate and return the next 14 days, one at a time
for (int i = 0; i < 14; i++) {
def date = dateFormat.format(currentDate.time)
log.info("date: $date")
// Return each date individually
result["date"] = date
// Increment the date by 1 day for the next iteration
currentDate.add(Calendar.DAY_OF_MONTH, 1)
}
Issue is however that I am getting a list of dates with always the same date, which is the date counted from today´s date:
Appreciate if anyone has a solution either for the Data Source --> Data Generator --> Date and Time and/or for the Data Source --> Groovy Script!