Forgive the title -- it needs work. I am struggling to find better English to express my issue. Edits encouraged.
Example to describe my issue:
I have an argument checking method called
public static void StringArgs.checkIndexAndCount(String, int, int). Given a string, an index, and a count, confirm the string is not null, and the index & counts are reasonable. Unchecked (runtime) exceptions are used to report errors. There is a battery of unit tests written to check all angles of this method.
Layered (or Derived) Method
The checker method is called by other methods, such as
public static String removeByIndexAndCount(String, int, int). The first line of this method checks the arguments by calling the above checker.
Unit Test Strategy
When I write unit tests for the second/layered/derived method, how do I account for the existing set of unit tests for the checker method? It seems to violate duplication/copy-paste principles to simple re-add the same unit tests (modified slightly) from the checker method to the second method.
My code is Java, but I don't think that particularly relevant, as this same issue could occur in any language.