You don't test an enum declaration. You may test whether some function input/output containhas the expected enum values. Example:
The purpose of tests is to ensure the unit or component confirms to the requirements.
enum Parity { Even, Odd } Parity GetParity(int x) { ... } Requirements should be defined in terms of interface, behavior or input/output, it shouldYou notdon't be defined in terms ofwrite tests verifying then enum Parity defines the implementation at the language levelnames Even and Odd.
A valid requirement for Such a function could for exampletest would be "the function should returnpointless since you would just be repeating what is already stated by the largest of two numbers"code. ButSaying the same thing twice does not make it shouldmore correct.
You notdo state implementation details like "the functions should contain anwrite tests verifying ifGetParity-statement say will return Even for 0, which..."Odd for 1 and so on. The reasonThis is valuable because you are not repeating the code, we want to be able to change/refactoryou are verifying the implementation and havebehavior of the tests confirmcode, independent of the function still works according to specimplementation. If the test is coupled to the implementationcode inside GetParity were completely rewritten, then we have to change the test if we change the implementation, which means we loosetests would still be valid. Indeed the benefitmajor benefits of the test (whenunit tests is they give you change both atfreedom to rewrite and refactor code safely, by ensuring the same time you might easily introduce an error) and we have twicecode still works as much work to doexpected.
TestingBut if you have a test which ensures an enum declarationdeclaration defines certain values, is testing the implementationexpected names, so this is bad. You want insteadthen any change you make to test that certain enum values in input have the desired effect, or certain operations returns the expected enum values. If someone deletes one of the expected values fromin the enum declaration, then obviouslyfuture will require you to change the test will fail (oralso. This means it is not compilejust twice as much work, depending onit also mean any benefit to the language), sounit test is lost. If you discoverhave to change code and test at the error that waysame time, then there is no safeguard against introducing bugs.