mardi 2 février 2021

Unit testing, assert equals if difference is not bigger than 1

Im new to Unit testing. I use Junit4, I have to compare two double numbers. But if difference is not longer than 1, it should pass. For example:

Assert.assertEquals(240, 241); //should pass
Assert.assertEquals(240, 239); //should pass

Assert.assertEquals(240, 242); //should fail
Assert.assertEquals(240, 238); //should fail

Is there way to implement it?

Aucun commentaire:

Enregistrer un commentaire