I am running with a test case in rest assured but it is failing with below error:
java.lang.AssertionError: 1 expectation failed. JSON path zero_base.herebyBreakdown doesn't match. Expected: with toString() "[{value=-365305.5f, value=-75133.81f, value=79750.484f, value=0.0f}]" Actual: [{value=-365305.5, value=-75133.81, value=79750.484, value=0.0}]
while, Actual results from post man are:
{
"value": -365305.5066
},
{
"value": -75133.816
},
{
"value": 79750.4868
},
{
"value": 0
}
Can someone please help me out here !
Looks like you compare floats to doubles.
Please make sure that compared values are the same type, or even better in case of floating-point numbers you should take into account that the resulting numbers might not be equal - and compare them with some error margin.
(For example in restassured/hamcrest there is sth like "closeTo", org.hamcrest.number.IsCloseTo
, for example:
assertThat(actual, is(closeTo(6, 0.5)));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.