As in simple word unit in the unit test is the unit behaviour/functionality of you application or system which you want to test. Your test case should test the unit behaviour not the method. Just aiming the small test in not produce a good quality test. It should make sense.
This is example from Vladimir Khorikov in his book -
A test should tell a story about the problem your code helps to solve, and this story should be cohesive and meaningful to a non-programmer.
For instance, this is an example of a cohesive story:
When I call my dog, he comes right to me.
Now compare it to the following:
When I call my dog, he moves his front left leg first, then the front right
leg, his head turns, the tail start wagging...
The second story makes much less sense. What’s the purpose of all those movements? Is the dog coming to me? Or is he running away? You can’t tell. This is what your tests start to look like when you target individual classes (the dog’s legs, head, and tail) instead of the actual behavior (the dog coming to his master)
Lets take an another practical code example, An classic ATM machine example. There is a ATM class, it include following methods
withdraw();
getBalance();
deposit();
You will write the test case to for deposit() something like this -
-makeASingleDeposite
and for withdraw() something like this -
-makeSingleWithDraw
-makeMultipleWithDraw
You have to test the behaviour of ATM class (SUT), withdraw() and deposit(). There is not need to write separate test case to test getBalance(). As to verify the withdraw and deposit behaviour in test case , you to verify balance by calling getBalance() method.
From the point of OOP, when you are test class, you are testing aggregate behaviour of class, not its individual methods.
In case of class, which not contains any state, like services or DAO's etc and you implemented business logic using Transaction Script pattern. Then your every method is behave like procedure and you can consider the method as unit. Write a test case considering functionality provided by that method.
Same in case of FP, your method/method or function is your unit.