Note that there are some explanatory texts on larger screens.

plurals
  1. POBDD with Cucumber and rspec - when is this redundant?
    text
    copied!<p>A Rails/tool specific version of: <a href="https://stackoverflow.com/questions/153234/how-deep-are-your-unit-tests">How deep are your unit tests?</a></p> <p>Right now, I currently write:</p> <ul> <li>Cucumber features (integration tests) - these test against the HTML/JS that is returned by our app, but sometimes also tests other things, like calls to third-party services.</li> <li>RSpec controller tests (functional tests), originally only if the controllers have any meaningful logic, but now more and more.</li> <li>RSpec model tests (unit tests)</li> </ul> <p>Sometimes this is entirely necessary; it is necessary to test behavior in the model that is not entirely obvious or visible to the end-user. When models are complex, they should definitely be tested. But other times, it seems to me the tests are redundant. For instance, do you test method <code>foo</code> if it is only called by <code>bar</code>, and <code>bar</code> is tested? What if <code>bar</code> is a simple helper method on a model that is used by and easily testable in a Cucumber feature? Do you test the method in rspec as well as Cucumber? I find myself struggling with this, as writing more tests take time and maintaining multiple "versions" of what is effectively the same behaviors, which makes maintaining the test suite more time intensive, which in turn makes changes more expensive.</p> <p>In short, do you believe there is there a time when writing only Cucumber features is enough? Or should you always test at every level? If you think there is a grey area, what is your threshold for "this needs a functional/unit test." In practical terms, what do you do currently, and why (or why not) do you think it's sufficient?</p> <hr /> <p><strong>EDIT</strong>: <a href="https://gist.github.com/6d02163e7c19c6ffeab0" rel="nofollow noreferrer">Here's an example of what might be "test overkill."</a> Admittedly, I was able to write this pretty quickly, but it was completely hypothetical.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload