在 JUnit 中测试最终类
所有,
我有一个类文件,用于存储在我的应用程序中使用的所有常量。类文件只包含常量和方法 JUnit 测试用例对于这样的类?如果是,我应该如何测试这样的类文件?
All,
I have a class file that is used to store all the constants that would be used 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从一开始就将整个应用程序的所有常量保留在一个类中听起来不是一个好主意。为什么要把它们从与价值最密切相关的类中分离出来呢?例如,如果您的身份验证请求有默认超时,请将其保留在您的身份验证服务(或其他服务)中。
如果您真的想要一个只有常量的类,我认为它不需要任何测试。测试应该运用逻辑——常量没有任何逻辑。
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.