Reputation: 63
I have a doubly linked list int
. I want to test Get()
method:
public E get (int index)
how many tests should I implement in JUnit to Cover fully cases ?
Thank you and hope to have answer soon.
Upvotes: 2
Views: 773
Reputation: 15622
Think of what behavior the list should have.
For each sentence you can build with the pattern:
given [data combination] as input the List should [expected behavior]
you should have a single test method.
When building this sentences you should consider valid input data as well as error conditions.
Upvotes: 0
Reputation: 1030
I think you can follow all tests below:
Get(0)
from an empty list.Get(-1)
from a list with 01 element Get(0)
from a list with 1 elementGet(1)
from a list with 2 element.Upvotes: 4
Reputation: 17605
Although the question is a bit broad, I think the following cases could be implemented.
Upvotes: 2