jeudi 8 octobre 2015

How to assert or validate 2 pieces of text that are "almost" identical for unit test

I'd like to validate an expected response against an actual from an actual API response as part of my unit tests.

So I have this:

Expectation:

disqualified because taxpayer can be claimed as dependent

I'd like to assert against this:

Actual:

disqualified because you can be claimed as a dependent

API response from a compiled binary.

Since these pieces of text are close enough, I'd like to pass this assertion I have in my test:

Assert.assertEquals(titleText.toLowerCase(), t.toLowerCase(), "Did not match!");

Since this assertion obviously did not pass because the 2 pieces of text are not equal.

I tried this instead:

Assert.assertTrue(titleText.toLowerCase().contains(t.toLowerCase()));

But the test still fails....How can I make this test pass? Any suggestions would be much appreciated.

Aucun commentaire:

Enregistrer un commentaire