DEV Community

Discussion on: Don't use non-test constants in unit tests

Collapse
 
scottshipp profile image
scottshipp

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.

Collapse
 
marcmacgonagle profile image
marcmacgonagle

You're right. If you don't intend to share it with your API users you shouldn't share it with your tests either.