Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't mutate and test all in one go #21

Open
dnlserrano opened this issue Nov 28, 2020 · 0 comments
Open

Don't mutate and test all in one go #21

dnlserrano opened this issue Nov 28, 2020 · 0 comments

Comments

@dnlserrano
Copy link
Owner

More context on this original post over at ElixirForum.com where I first explained it.

Right now I’m not running each test ... do individually but instead I’m running the whole test module (e.g., HelloWorldTest). This has one clear disadvantage, which I’ll explain below with an example:

defmodule HelloWorld do
  def sum(a, b) do: a + b
  def divide(a, b), do: div(a, b)
end
defmodule HelloWorldTest do
  test "when testing sum" do
    assert HelloWorld.sum(3, 0) == 3
  end

  test "when testing divide" do
    assert HelloWorld.divide(5, 2) == 3
  end
end

If I change code to the following:

defmodule HelloWorld do
  def sum(a, b) do: a - b # changed from + to - via AOR1
  def divide(a, b), do: div(a, b)
end

I will be running the tests for both tests, instead of just running the test for sum/2 (i.e., "when testing sum", which was the only one for which the corresponding source code changed). In order to try and maximise the amount of mutations I can catch with running the entire test module, I mutate all in one go. Does that make sense? Maybe it doesn’t… 🤦‍♂️ AFAIU, finding out what tests I should run per source code change is hard (or at least not trivial? 😅). But I might not be seeing something very obvious.

Hope people can help out with ideas for this one. Maybe traversing tests and annotating to keep track of what operators are present in each and hence are influenced/swing based on mutations performed? 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant