Daniel Lubarov

Better parameterized tests with Burst

At Square, we wrote a Java library called Burst for parameterizing JUnit tests. You just declare enum parameters in your test's constructor or methods, and Burst will generate a separate test for each combination of enum values. For example:

@RunWith(BurstJUnit4.class)
public class WebServerTest {
  enum Protocol { HTTP_1_0, HTTP_1_1, HTTP_2 }
  enum Method { GET, PUT, POST }

  private final Protocol protocol;

  public WebServerTest(Protocol protocol) {
    this.protocol = protocol;
  }

  @Test public void testConnect() {
    connect(protocol);
  }

  @Test public void testRequest(Method method) {
    dispatchRequest(protocol, method);
  }
}

This test would "burst" into the following hierarchy:

See our blog post for more details, or check out the project on GitHub.