Other build tools

The most straightforward way to run specs2 specifications is to use sbt. However other build tools such as Maven and Gradle can be used too (please refer to the Installation guide for instructions on how to set-up projects for those tools).


With Maven you need to use the Surefire plugin and the test command. You will need however to annotate your specification classes as JUnit tests (this requires the specs2-junit jar):

import org.specs2.runner.JUnitRunner
import org.junit.runner.RunWith

class MySpecification extends org.specs2.Specification { def is = s2"""
  Define your specification as usual here


With Gradle you need to use the same RunWith annotation and the test task. You can also follow the instructions in this blog post and create a task that will leverage the specs2 file runner. This way you will avoid having to annotate the classes.