Alex Rivera | Logout

assert vs. JUnit Assertions

Asked 2010-06-03T13:26:46.403
110

Today I saw a JUnit test case with a java assertion instead of the JUnit assertions—Are there significant advantages or disadvantages to prefer one over the other?

Edit
Report

1 Answer

27

When a test fails you get more infomation.

assertEquals(1, 2); results in java.lang.AssertionError: expected:<1> but was:<2>

vs

assert(1 == 2); results in java.lang.AssertionError

you can get even more info if you add the message argument to assertEquals

answered 2011-06-07T14:57:11.283

Your Answer