Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert assertTrue/assertFalse to assertEquals.. #219

Open
notthetup opened this issue Aug 27, 2021 · 2 comments
Open

Convert assertTrue/assertFalse to assertEquals.. #219

notthetup opened this issue Aug 27, 2021 · 2 comments
Assignees
Labels

Comments

@notthetup
Copy link
Collaborator

notthetup commented Aug 27, 2021

When testing something we can either use assertTrue(server.errors == 0) or assertEquals(server.errors, 0)

From a test perspective, there is no difference, when the test fails the way both of them are reported is different.

The former gives

org.arl.fjage.test.fjagejsTest > fjageJSTest FAILED
    java.lang.AssertionError
        at org.junit.Assert.fail(Assert.java:86)
...

whereas the latter prints out the values in the stack trace which are very useful when debugging errors (especially on CI where it's hard to get access to the HTML reports).

org.arl.fjage.test.fjagejsTest > fjageJSTest FAILED
    java.lang.AssertionError: expected:<1> but was:<0>
        at org.junit.Assert.fail(Assert.java:88)

Even better would be adding a string explanation of what the assert does assertEquals("ensure no errors were on the server after requesting to send 10 messages", server.errors, 0)

@mchitre
Copy link
Member

mchitre commented Aug 27, 2021

Even better might be to consider moving to Spock :-), and all this is done automagically

@notthetup
Copy link
Collaborator Author

That works even better!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants