Skip to main content
added 472 characters in body
Source Link
Heinzi
  • 9.9k
  • 3
  • 50
  • 60

I'd take the pragmatic approach here: If someone, in the future, overrides Manager::getMail, then it is that developer's responsibility to provide test code for the new method.

(That is, Of course that's only valid if Manager::getEmail really has the same code path as Employee::getEmail.! Even if the method is not overridden, this must not necessarily be the caseit might behave differently: If, for example

  • Employee::getEmail could call some protected virtual getInternalEmail which is overridden in Manager.
  • Employee::getEmail could access some internal state (e.g. some field _email), which can differ in the two implementations: For example, the default implementation of Employee could ensure that _email is always [email protected], but Manager is more flexible in assigning mail addresses.

In such cases, it is possible that a bug manifests itself only in EmployeeManager::getEmail calls some protected virtual getInternalEmail which, even though the implementaion isof the method itself overridden in Manager, thenis the same. In that case testing Manager::getEmail separately doescould make sense.)

I'd take the pragmatic approach here: If someone, in the future, overrides Manager::getMail, then it is that developer's responsibility to provide test code for the new method.

(That is, if Manager::getEmail really has the same code path as Employee::getEmail. Even if the method is not overridden, this must not necessarily be the case: If, for example, Employee::getEmail calls some protected virtual getInternalEmail which is overridden in Manager, then testing Manager::getEmail separately does make sense.)

I'd take the pragmatic approach here: If someone, in the future, overrides Manager::getMail, then it is that developer's responsibility to provide test code for the new method.

Of course that's only valid if Manager::getEmail really has the same code path as Employee::getEmail! Even if the method is not overridden, it might behave differently:

  • Employee::getEmail could call some protected virtual getInternalEmail which is overridden in Manager.
  • Employee::getEmail could access some internal state (e.g. some field _email), which can differ in the two implementations: For example, the default implementation of Employee could ensure that _email is always [email protected], but Manager is more flexible in assigning mail addresses.

In such cases, it is possible that a bug manifests itself only in Manager::getEmail, even though the implementaion of the method itself is the same. In that case testing Manager::getEmail separately could make sense.

added 1 characters in body
Source Link
Heinzi
  • 9.9k
  • 3
  • 50
  • 60

I'd take the pragmatic approach here: If someone, in the future, overrides Manager::getMail, then it is that developer's responsibility to provide test code for the new method.

(That is, if Manager::getEmail really has the same code path as Employee::getEmail. Even if the method is not overridden, this must not necessarily be the case: If, for example, Employee::getEmail calls some protected virtual getInternalEmail which is overridden in Manager, then testing Manager::getEmail separately does make sense.)

I'd take the pragmatic approach here: If someone, in the future, overrides Manager::getMail, then it is that developer's responsibility to provide test code for the new method.

(That is, if Manager::getEmail really has the same code path as Employee::getEmail. Even if the method is not overridden, this must not necessarily be the case: If, for example, Employee:getEmail calls some protected virtual getInternalEmail which is overridden in Manager, then testing Manager::getEmail separately does make sense.)

I'd take the pragmatic approach here: If someone, in the future, overrides Manager::getMail, then it is that developer's responsibility to provide test code for the new method.

(That is, if Manager::getEmail really has the same code path as Employee::getEmail. Even if the method is not overridden, this must not necessarily be the case: If, for example, Employee::getEmail calls some protected virtual getInternalEmail which is overridden in Manager, then testing Manager::getEmail separately does make sense.)

Source Link
Heinzi
  • 9.9k
  • 3
  • 50
  • 60

I'd take the pragmatic approach here: If someone, in the future, overrides Manager::getMail, then it is that developer's responsibility to provide test code for the new method.

(That is, if Manager::getEmail really has the same code path as Employee::getEmail. Even if the method is not overridden, this must not necessarily be the case: If, for example, Employee:getEmail calls some protected virtual getInternalEmail which is overridden in Manager, then testing Manager::getEmail separately does make sense.)