Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Junit test methods

Tags:

java

junit

What are the most oftenly used test methods I should start with in order to get familiar with unit testing? There are just a lot of them, but I guess there are some like common or something.

I meant Junit methods like AssertTrue(), etc.

like image 576
Eugene Avatar asked Dec 23 '22 00:12

Eugene


1 Answers

There are just a few patterns to learn, with multiple implementing methods for different types and an optional initial message argument.

  • assertEquals()
  • assertTrue() and assertFalse()
  • assertNull() and assertNotNull()
  • assertSame() and assertNotSame()
  • fail()
  • assertArrayEquals()
  • assertThat()

At a minimum you'll need to learn all the patterns but the last -- these are all needed for different situations.

like image 89
Andy Thomas Avatar answered Feb 24 '23 07:02

Andy Thomas