简体   繁体   English

如何测试一个充满常数的类

[英]How to test a class full of constants

There is a class in my project which is just constants as follows: 我的项目中有一个仅是常量的类,如下所示:

public class AppConstants
{
  public static String Foo = "Foo";
  public static String Bar = "Bar";
  // so on...
}

Ok these can be marked readonly/final etc. 好的,这些可以标记为readonly/final等。

How can i test this class or make it testable? 我如何测试此类或使其可测试? same idea for a Enum ? Enum相同的想法吗?

I dont see anything to test but for the sake of testability how can i improve it? 我看不到要测试的任何内容,但出于可测试性,我该如何改进?

What is there to test? 有什么要测试的? So you have a class full of public, static variables (those are not constant, regardless of the name of the class)... there is no logic here. 因此,您有一个充满公共静态变量的类(无论类的名称是什么,它们都不是常数)……这里没有逻辑。 As long as the compiler knows how to generate valid bytecode (it does) and as long as the CLR knows how to interpret said bytecode (it does), there is no problem. 只要编译器知道如何生成有效的字节码(确实如此),只要CLR知道如何解释所述字节码(确实如此),就没有问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM