Search code examples
unit-testingtestingexploratory

Unit Test Vs Exploratory Test in short term/long term scenarios


What do you think brings more value to the product, Unit Test or Exploratory Test?

I understand that both tests serve different general purposes, but what test would you prioritize, i.e. what would you do first and what second, Unit or Exploratory?

Also, which one pays more benefits in the short term? and in the long term?

Finally, would your answer change if you had only time for one of the two?


Solution

  • In my opinion both are critical. I follow a TDD methodology, so unit tests form an executable specification of my code. Unit tests must be done first, but often in the process I find myself doing some forms of exploratory testing to create my passing unit test. Further, there are somethings -- interface design, for example -- that cannot be fully developed without some form of exploration. Yes, you can in many cases develop unit tests to ensure that interface elements operate the way they are expected to, but you often need to see how different elements do interact before you can determine how they should interact. Exploring different scenarios and adjusting the test script based on feedback is an important part of the design.

    For non-interface work, I would do unit tests first and exploratory tests as needed. For interface work, I would prototype and explore, then develop unit (scripted) tests after, if at all. This is partly due to the capabilities of test tools in each space, but that is related to the type of work being done as well.

    As to benefits, it's hard to compare because they provide different kinds of benefits. Both types of testing can find and eliminate defects, but unit testing (using TDD) guides and improves the design and structure of the application as well. By improving the design, we also improve maintainability. Exploratory testing, in my opinion, primarily improves the usability of the application, though it can be used to evaluate whether our design decisions actually work the way we expect and validate the design as it evolves.

    My opinion is that unit tests are more foundational in that they provide a safety net from which all other tests can work to produce change. In that sense they are more important, but you cannot do without either in a realistic environment. Also, these aren't the only two types of testing, nor are they really directly comparable, in the same way as unit and integration tests are. You can do unit tests that are explorations if you want using the debugger.

    I can imagine scenarios in which you wouldn't have time to do automated, scripted tests but these are edge cases, at least for me. I can't imagine a scenario where I wouldn't do some level of unit testing even if using manual, exploratory tests. The application would have to be dead simple, indeed, before some level of unit testing isn't necessary.