DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

peter has posted 1 posts at DZone. View Full User Profile

Scalatest - Maven Integration

  • submit to reddit
        import collection.jcl.ArrayList
import org.scalatest._

trait MavenSuite extends Suite {
  class MavenReporter() extends Reporter {
    val errors = new ArrayList[Report]()

    override def testFailed(report: Report) {
  var mavenReporter = new MavenReporter()

  def testForMaven() = {
    //first see whether any tests failed
    execute(None, mavenReporter, new Stopper {}, Set(), Set("org.scalatest.Ignore"), Map(), None);
    //if any test failed we will need to a) execute the tests again using the console printer and b) make sure the build fails
    if (mavenReporter.errors.size > 0) {

// and the test class signature could look like something like:
class SomeTest extends MavenSuite with Spec with ShouldMatchers{ ...