开发者

Testing a final class in JUnit

开发者 https://www.devze.com 2023-01-25 09:34 出处:网络
All, I have a class file that is used to store all the constants that would be use开发者_运维问答d throughout my application. The class file contains only constants and methods JUnit test case for su

All,

I have a class file that is used to store all the constants that would be use开发者_运维问答d throughout my application. The class file contains only constants and methods JUnit test case for such a class? If yes, how should I test such a class file?


It doesn't sound like a great idea to keep all the constants for the whole application in a single class to start with. Why separate them from the class which is most closely related to the value? For example, if you have a default timeout for authentication requests, keep it with your authentication service (or whatever).

If you really want to have a class with just constants, I don't think it needs any tests. Tests should exercise logic - constants don't have any logic.

0

精彩评论

暂无评论...
验证码 换一张
取 消