Forum Discussion

yognsal's avatar
yognsal
Occasional Contributor
7 years ago

Contains assertion

Hi I have below json response format. My all the data is constant except the date which chnages every day. due to this i am not able to validate the response using contains assertion. Is there an...
  • bagochips's avatar
    7 years ago

    add a groovy step to create your variable date

    If you want today's date as the date to check you can add this

     

    myDate = new Date()
    context.testCase.setPropertyValue("date", myDate.format("MM-dd-yyyy 00:00:00"))

    and then in your assertion step put this in to pull the variable from your property

     

     

    ${#TestCase#date}

    if you are wanting to dynamically get tomorrows date then

    myDate = new Date()
    myDate = myDate - 1
    context.testCase.setPropertyValue("date", myDate.format("MM-dd-yyyy 00:00:00"))

     

  • JHunt's avatar
    JHunt
    7 years ago
    testRunner.testCase.testSuite.project.getTestSuiteList().each {
        it.getTestCaseList().each { tc ->
            myDate = new Date()
            tc.setPropertyValue("date", myDate.format("dd-MM-yyyy 00:00:00"))
        }
    }