Answer the question
In order to leave comments, you need to log in
What should be unit testing cases?
I recently started doing unit testing and wondered what cases I need to test the code for.
I singled out for myself: for checking calls to locked methods, for checking for null and for expected errors in various cases. What cases could I have missed and do I understand unit testing correctly in principle?
Answer the question
In order to leave comments, you need to log in
Basically, you are correct.
Unit tests are designed to provide two types of checks - results checks and behavior checks.
For example, we are testing a method for sorting an array of strings.
The first check is obvious: The
second case is more difficult:
sort(null)
sort({})
sort({"a"})
sort({"c", null "b"})
sort({"c", "", "b"})
sort({"b", "a", "b"})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question