I think the question for me here is around whether or not the constant is part of the API?
If it was I'd expect a test for the value of the constant, which would alleviate the second problem. And if the API changes shouldn't the tests change too?
For instance, I'd expect Integer.MAX_VALUE to be part of the test suite for Integer.
Yes agree with this. Constants that are part of the API like Math.PI or Integer.MAX_VALUE should be tested.
Although you'd definitely think other tests would fail if these values were wrong.
I've just seen code recently where the only reason something was made "part of the public API" was actually just so it could be shared into the test code, not that it had a valid reason to be there.
if the API changes shouldn't the tests change too? - no. Well, the tests should of course change. But the most important thing is, that this change should not be done automatically. The test should be changed manually, so that we have a chance to review the changes needed, to think about desired behaviour, about alternative.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I think the question for me here is around whether or not the constant is part of the API?
If it was I'd expect a test for the value of the constant, which would alleviate the second problem. And if the API changes shouldn't the tests change too?
For instance, I'd expect Integer.MAX_VALUE to be part of the test suite for Integer.
Yes agree with this. Constants that are part of the API like Math.PI or Integer.MAX_VALUE should be tested.
Although you'd definitely think other tests would fail if these values were wrong.
I've just seen code recently where the only reason something was made "part of the public API" was actually just so it could be shared into the test code, not that it had a valid reason to be there.
You're right. If you don't intend to share it with your API users you shouldn't share it with your tests either.
if the API changes shouldn't the tests change too? - no. Well, the tests should of course change. But the most important thing is, that this change should not be done automatically. The test should be changed manually, so that we have a chance to review the changes needed, to think about desired behaviour, about alternative.