Reputation: 186
I am developing my App through TDD practice with JUnit. I need to make sure that the parameter passed to the method exists in the class dictionary (Hashmap). For this I use assertEquals, comparing mock dictionary object and method. However, IDEA says that it is wrong. What's wrong? Junit method:
public void testDictEqualsAddedWord(){
controller.addWord("cat");
assertEquals(mockedDict, controller.addWord("cat"));
}
Upvotes: 1
Views: 178
Reputation: 40356
Your assertion is that mockedDict is equal to the result of calling controller.addWord("cat"). That's unlikely to be correct. What you probably want to assert is that, after adding the word "cat" to the map, that the map now contains the word "cat".
Upvotes: 2