|
|
|
|
|
by zmgsabst
950 days ago
|
|
The behavior has changed: Checking length is now a function call and not a cached variable — a change in call signature and runtime performance. Consumers of your list class are going to have to update their code (eg, that checks the list length) and your test successfully notified you of that breaking API change. |
|
The API of a piece of code is a convention, sometimes compiler enforced, typically not entirely. If that convention is broken, it's good that tests fail. If changes outside that convention break tests, then it's pure overhead to repair those tests.
As a side note, the length check is not necessarily no longer cached just because the variable is no longer visible to that test. Perhaps the custom list implementation was replaced with a wrapper around java.ArrayList, so the length field is no longer accessible.