mutant icon indicating copy to clipboard operation
mutant copied to clipboard

mutating methods delegated by forwardable?

Open jfredett opened this issue 11 years ago • 1 comments

IRC Discussion: http://irclog.whitequark.org/mutant/2013-09-29

We talked about classes that look like:


require 'forwardable'
class Foo
  delegate :bar => :baz
  #or 
  def_delegator :target, :method, :alias

  # snip
end

In particular, mutant presently simple says it can't find the corresponding method body and skips testing the delegated method. It might be good to mangle the incoming/outgoing parts of that delegation to ensure there's test coverage on:

  1. the API existing on Foo (eg that I can call Foo#bar)
  2. the Delegation actually being valid (eg, that delegating #bar => #baz is reasonable)
  3. that any aliasing is also covered -- ie, that aliasing to some other method won't cause a mutant to survive.

Those points should probably be debated on whether or not it's good to encourage those sorts of tests, I mentioned in IRC a recent Sandi Metz talk on how to write maintainable, flexible tests (from RailsConf 2013), it might be worth looking at when deciding how to proceed.

jfredett avatar Sep 29 '13 20:09 jfredett

@jfredett Thx for that detailed summary of our discussion. I'll think/research about this ideas.

mbj avatar Sep 29 '13 20:09 mbj