Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unit testing Scala

I just recently started learning the Scala language and would like to do it in TDD-way. Could you share your experiences on the unit testing frameworks there are for Scala and the pros/cons of them.

I'm using IntelliJ IDEA for Scala development, so it would be nice to be able to run the tests with IDE-support.

like image 771
Kaitsu Avatar asked Apr 12 '09 07:04

Kaitsu


People also ask

What is Scala unit testing?

ScalaTest is a popular choice to test Scala projects. It has been used by well-known open-source projects such as Akka. In this course, Unit Testing in Scala, you will learn how to test a Scala project using ScalaTest. First, you will test your codebase using Assertions and Matchers.

Which testing framework have you used for Scala?

There are two outstanding Scala testing frameworks: ScalaTest and ScalaCheck. Both are easy to use, but there are a few differences depending on the test approach you want to use. This specification for Rooms indicates that the property that rules if the room is available has to check for all possible rooms.


1 Answers

Have you looked at ScalaTest ?

I've not used it, but it comes from Bill Venners and co at Artima, and consequently I suspect it'll do the job. It doesn't appear to have IDE integration, however.

This blog entry is a little old, but suggests that TestNG is the best option for testing Scala. TestNG will certainly have IDE integrations.

EDIT: I've just realised that I wrote this answer in 2009, and the world has moved on (!). I am currently using ScalaTest, the IDE integration works fine, and I can strongly recommend it. In particular the matcher DSL works very nicely

like image 55
Brian Agnew Avatar answered Oct 08 '22 12:10

Brian Agnew