The idea of using Scala to build unit tests for Java code has been thrown around. People are making the claim that Unit tests would be less effort to write because there's less boilerplate. In addition Scala, provides other "features" to provide "better" tests. Has anyone gone through this evaluation, and can you explain the pros/cons of using Scala for Java unit testing?
|
I don't have a direct answer to your question, but perhaps you can infer some things about Scala-based testing from my experience with Clojure -- another JVM-based language -- for testing against Java APIs I definitely believe some languages are better for writing tests than others. A lot of testing is about trying many variations of the same operation. My experience is that the number of keystrokes necessary to express test variations is smaller in Clojure than in Java. As you said, there's less boilerplate. Since Clojure has a REPL, I can usually edit/run/debug tests without having to recompile. There are downsides:
All of these are impediments. Whether they are compelling enough to avoid coding tests in something other than the product's native language depends on the culture and expertise in your organization. |
|||||||||||||
|