jeudi 22 novembre 2018

How to use hamcrest matchers in Testng assertEquals?

I am currently using testng assertEquals and softassertion, No I have a scenario of validation wher the actual is a complete string and the expected is a substring.

Code

assertThat("This is actual string",containsString("expected"));

Error message

java.lang.NoSuchMethodError: org.hamcrest.Matcher.describeMismatch(Ljava/lang/Object;Lorg/hamcrest/Description;)V

Code

softAssert.assertEquals("This is actual 
string",containsString("actual"));

Error message

java.lang.AssertionError: The following asserts failed: expected [a string containing "actual"] but found [This is actual string] Expected :a string containing "actual" Actual :This is actual string

Aucun commentaire:

Enregistrer un commentaire