Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • 6
    But that's useless. You'd be checking if the message thrown is the same message that would be thrown. Literally checking if the constant is a constant. At best, it verifies if the constant template is used but that's hardly useful - what if somebody mistakenly sets the constant to an empty string? it's still used but it's not terribly useful for any consumer of that message even when your test passes. Commented Mar 5, 2020 at 7:45
  • The thing about constants... nobody can mistakenly set the constant to an empty string. So instead of comparing against "status is not WAITING", you'd compare against the constant TEXT_FOR_EXCEPTION_STATUS_IS_NOT_WAITING. Commented Mar 5, 2020 at 21:20
  • 1
    Why would nobody be able to set it? If they are doing a refactoring and mistakenly change the sourcecode from (effectively) MY_CONSTANT = "Some text here" to (effectively) MY_CONSTANT = "" then what good is it that your test of (essentially) "" == "" passes? Commented Mar 5, 2020 at 21:23
  • 2
    You've not explained what the test of "is an empty string an empty string" good for. Because that's what you're transitively testing for. Whereas I believe that a test should have use so that a pass would mean something. If it passes and you still have a problem, then you need another test...to check if the constant you're checking for has the content you expect. Which brings us back at square one. Commented Mar 5, 2020 at 21:26