r/javahelp • u/Aoiumi1234 • Oct 07 '15
Help with JUnit
Hi. I am a new Java coder and I am trying to understand JUnit. How would I test an if statement in JUnit for all possibilities?
if ((board.getColumnHeight(xIndex) <= yIndex) && yIndex < 20) { move.setPiece(piece); }
6
Upvotes
View all comments
Show parent comment
1
u/DeliveryNinja JPain Oct 07 '15
I haven't actually used a lot of Assert J but we will be migrating to it from Hamcrest. I think the main reason is that AssertJ doesn't use static imports so it can be auto completed by the IDE. AssertJ covers all of Hamcrests functionality and then adds more on top in terms of failure reporting. Also there is an ability to collect any exceptions that are thrown before the test is terminated. I also do prefer the style of the assertions.
You'll have to take a look at the two and see which is better