canonical / is-charms-contributing-guide

The code contributing guide for the IS charms team
Apache License 2.0
2 stars 1 forks source link

Standard for checking error/ log messages #4

Open jdkandersson opened 2 years ago

jdkandersson commented 2 years ago
mthaddon commented 2 years ago

I agree checking for an entire log message can mean your tests need changing if a log message changes, but I also think having an explicit log message in the tests makes it much easier to read the tests, and can potentially catch issues that checking individual words might not. For example "The jenkins relation was not joined due to an incompatible error" and "Jenkins relation joined" would both match if you were only looking for the keywords relation and joined although the meaning is completely different.

jdkandersson commented 2 years ago

It is a good point, it is a trade-off. In practice it helps to pick words or phrases that are unique to the log message being looked for and it also helps to include dynamic elements of the log message (such as the name of a unit) to check that it correctly made it in.