views:

955

answers:

4

My company is beginning to write some code using Scala. I've been moved onto this project, and am a big fan of TDD, so I would like to get a unit-testing framework in place. However, the build system we're using for this project is Maven, and that's not going to change, for a variety of reasons.

I've looked at both ScalaTest and ScalaCheck, and both seem to have issues with Maven integration. Various forum posts I've seen in Google searches indicate that some of the Suites included with ScalaTest won't run under the maven-scala-plugin, and I haven't been able to find any information at all on running ScalaCheck in Maven's test goal.

Can anyone either point me at a way to get ScalaTest/ScalaCheck running reliably with Maven, or suggest an alternative?

+3  A: 

To answer my own question: It appears that the JUnit4Runner package located here provides the necessary glue to integrate ScalaTest's full functionality with Maven. Also, rumor has it that the next version of ScalaTest will include something like this.

MattK
+8  A: 

Hi Matt,

You can also use specs to declare specifications and execute them as JUnit tests with Maven. This works fine, as described here: http://code.google.com/p/specs/wiki/RunningSpecs#Run_your_specification_with_JUnit4

If you have any issue with that, please post a mail on the users mailing list.

Thanks,

Eric.

PS: you can also use ScalaTest and ScalaCheck from specs if you want to access some of these libraries features.

Eric
I like specs, and found it easy to run from within Eclipse as JUnit tests.
Kevin Peterson
+6  A: 

ScalaTest 1.0 has:

org.scalatest.junit.JUnitRunner

You can use it with JUnit's RunWith annotation. Maven likes that. There's also a Maven plugin now for ScalaTest, written by Jon-Anders Teigen. Right now you'll need to grab it from Jon-Anders github page:

http://github.com/teigen/maven-scalatest-plugin

Soon we plan to deploy it "officially" in a Maven repository.

Bill Venners