Testing Permutations of Interactions Between Features in Elixir and Phoenix.

Photo by Crawford Jolly on Unsplash

Testing Interactions Between Features.

When testing interactions, permutations of test cases grow exponentially.

  1. Filter by full book title should find matching books.
  2. Filter by partial book title should find matching books.
  3. Filter by no book title should find all books.
  4. Filter by non-matching book title should find no books.

Selectively Test Interactions.

One option for handling a large number of test permutations is to test interactions selectively.

green = test case to test
  • filter by author full name and book full title finds matching books.
  • Partial name author partial name book finds matching books.
  • No author name, no book name finds all books.
  • Non-matching author name and non-matching book name finds no books.
  • Filter by full book title and partial author name finds matching books.
  • Filter by partial book title and non-matching author name finds no books.
  • Filter by no book title and no author name finds matching books.
  • Filter by non-matching book title and full author name finds no books.

You Don’t Always Need to Test Every Interaction.

Sometimes you can skip certain cases if you are willing to sacrifice test coverage. You can sprinkle in tests for interactions as needed.

Test Exceptional Cases.

You may also have certain edge cases that defy normal behavior. For example, when filtering by an author and a non-matching book title, the default behavior is to return non-books. However, since users are looking for an author’s book, they may enter its title wrong. In this case, it may be better to return some possible suggestions to the user rather than returning nothing.

Summary

You can handle testing permutations of interactions by selectively testing interactions directly rather than creating a test for every possible permutation of test cases.

  • Can you introduce a bug (on purpose) without the tests catching it?
  • If you remove the interaction tests covering both author name and book title together, what bugs can you introduce while tests still pass?

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Brooklin Myers

Brooklin Myers

Software Engineer. I create educational content focused on technology for mobile and web applications.