1

I am doing regression testing. In my Aplication I am giving assertEquals() command for time period which is in miliseconds.But it has very small changes time period and my testcase failed.So I want to add Tolerance for 10milisec. How to add Tolerance?

1

Can you please try this pseudo code:

bool public verifyWithTolerance(timeStamp) 
{
    lowerEnd = 500 miliseconds;
    higherEnd = 1000 miliseconds;
    if (timeStamp > 500 && timeStamp < 1000)
    {
        return True;
    }
    else {return False;}
}

assertTrue(verifyWithTolerance(timeStampYouWantToVerify))
1

You can use AssertJ which has the expected assertion:

assertThat(duration).isCloseTo(expectedDuration, offset(10));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.