0

I have method which contains multiple Assertions, all are passing except last one and it shows all the assertion messages even if it is passed. Does anybody knows how to resolve such condition and how can i get only failure message instead of all messages in console.

    Assertions.assertThat(actual.getAttribute("id").isEqualTo("first_name");
    Assertions.assertThat(actual.tagName()).isEqualTo("input");
    Assertions.assertThat(actual.getAttribute("class")).isEqualTo("input-group");
    Assertions.assertThat(actual.getText()).isEqualTo("John");

The above is the code which i have written and all condition are getting passed except last but it shows like this as mentioned below.

Expected actual to be first_name but got <first_name>

Expected actual to be input but got <input>

Expected actual to be input-group but got <input-group>

Expected actual to be Johny but got John

Actually last statement is failure but it shows all the messages as above even if that conditions have got passed.

Madhav Saraf
  • 100
  • 1
  • 9
  • 1
    which assertion framework are you using? Assertions is a custom class that you have created? Cause then we will need to do see Assertions classes – Mrunal Gosar Oct 02 '19 at 14:23
  • I am using AssertJ - Fluent Asssertion API [Assertion API](http://joel-costigliola.github.io/assertj/index.html) This is my class definition using AssertJ API `public class MyAssert, ACTUAL extends ActualClass> extends AbstractAssert` – Madhav Saraf Oct 03 '19 at 04:24

1 Answers1

1

You will get better help if you post a code sample to reproduce the issue.

The code you have contains typoes as Assertj provides an isEqualTo and you are using isEqualsTo.

Joel Costigliola
  • 6,308
  • 27
  • 35
  • I have fixed the typos in the code section. Thanks for the suggestion ! – Madhav Saraf Oct 04 '19 at 11:05
  • unfortunately, you are not giving enough information for people to be able to help, provide a reproducible test case and I'm sure you'll get help. – Joel Costigliola Oct 05 '19 at 23:05
  • I would have given the code but our company policy does not allow to disclose. But i will share parallel example with you. – Madhav Saraf Oct 07 '19 at 09:28
  • May be what is being asked is following: MyAssert.assertThat(actual).hasFirstName("Siddhant");//Will have no errors MyAssert.assertThat(actual).hasLastName("Chothe");//Will have no errors MyAssert.assertThat(actual).hasFullName("Siddhant Something");//Only this will generate error. But MyAssert.assertThat(actual) .hasFirstName("Siddhant") .hasLastName("Chothe") .hasFullName("Siddhant Something");//Would give all three messages at once. – sidnc86 Oct 07 '19 at 11:05
  • There was an MessageComposer class that i was building, which had that error Sorry for the inconvenience caused.[Closed] – Madhav Saraf Oct 07 '19 at 12:49