rbs icon indicating copy to clipboard operation
rbs copied to clipboard

[test] Test coverage

Open soutaro opened this issue 6 years ago • 0 comments

There is no way to measure how well the tests cover the method call variations.

Assume we have a method definition like:

def foo: (Integer | String) -> (Symbol | Array[String])
       | (Integer, String) -> void

We may write a test for the method like:

def test_foo
  foo(1)
  foo(1, "3)
end

It covers part of the first overload and second overload, but we need more cases to cover all of the variations.

def test_foo
  foo(1)              # Assume this returns Symbol
  foo("foo")          # Assume this returns Symbol
  foo(3)              # Assume this returns Array[String]
  foo(1, "3)
end

So, having a tool to measure the coverage would help writing tests.

soutaro avatar Jan 08 '20 08:01 soutaro