0

I have some values in property files that are integers. Should I write a unit test to check if they are integers? If yes how do we accomplish this. I am not loading the properties into variables. Simply using them directly where required

wib
  • 425
  • 3
  • 17

2 Answers2

2

Unit testing is for testing your artifacts (stuff you produce as part of your application/product), not your configuration. If the properties file is something that can change outside of your control, the correct thing to do is to check it on use.

In other words, you should have your code check that the properties are integers and then unit-test that code to ensure it correctly imports integers and rejects everything else (floating point, integers with trailing rubbish, non-numeric strings, empty strings and so on).

paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953
0

Unit testing is not for properties files. The proper way to handle bad values in your properties file is with RuntimeExceptions or Errors in the code where they are used

ControlAltDel
  • 33,923
  • 10
  • 53
  • 80