RSpec vs Cucumber (RSpec stories) [closed]

If you haven’t already, you might want to check out Dan North’s excellent article, What’s in a Story? as a starting point. We have two main uses for Cucumber stories. First, because the story form is very specific it helps focus the product owner’s articulation of the features he wants built. This is the “token … Read more

Junit: splitting integration test and Unit tests

You can split them very easily using JUnit categories and Maven. This is shown very, very briefly below by splitting unit and integration tests. Define A Marker Interface The first step in grouping a test using categories is to create a marker interface. This interface will be used to mark all of the tests that … Read more

Is duplicated code more tolerable in unit tests?

Readability is more important for tests. If a test fails, you want the problem to be obvious. The developer shouldn’t have to wade through a lot of heavily factored test code to determine exactly what failed. You don’t want your test code to become so complex that you need to write unit-test-tests. However, eliminating duplication … Read more

Separating unit tests and integration tests in Go

@Ainar-G suggests several great patterns to separate tests. This set of Go practices from SoundCloud recommends using build tags (described in the “Build Constraints” section of the build package) to select which tests to run: Write an integration_test.go, and give it a build tag of integration. Define (global) flags for things like service addresses and … Read more

Can unit testing be successfully added into an existing production project? If so, how and is it worth it?

I’ve introduced unit tests to code bases that did not have it previously. The last big project I was involved with where I did this the product was already in production with zero unit tests when I arrived to the team. When I left – 2 years later – we had 4500+ or so tests … Read more