I am completely new to Junit and unit testing and I would like to start unit testing my code. I would like to start with a method that looks like the following:
public Store loadStore(Integer customerId,
Integer storeId){
//The logic of this method selects a store from a database based on the parameter criteria
}
From this article http://www.vogella.com/articles/JUnit/article.html I have read that the following assertions can be made:
- fail(String) assertTrue(true)
- assertTrue([message], boolean condition)
- assertsEquals([String message], expected, actual)
- assertsEquals([String message], expected, actual, tolerance)
- assertNull([message], object)
- assertNotNull([message], object)
- assertSame([String], expected, actual)
- assertNotSame([String],expected, actual)
I am confused about which assertion to use for this method. Should I use several? Should I use one? What should be trying to prove with the unit testing of this method?
1 Answer