Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you unit test Scala in Eclipse?

I am learning Scala and would like to set up integrated unit testing in Eclipse. As far as I can tell from googling, ScalaTest is the way to go, possibly in combination with JUnit.

What are your experiences with unit testing Scala in Eclipse? Should I use the JUnit runner or something else?

like image 947
Jørgen Fogh Avatar asked Jun 06 '10 12:06

Jørgen Fogh


Video Answer


2 Answers

There is a wiki page on the ScalaIDE website on how to run Scala unit tests in Eclipse. If you have specific issues with running specs unit tests, I encourage you to post messages on the specs-users mailing list.

Eric.

like image 59
Eric Avatar answered Sep 20 '22 12:09

Eric


I was unable to run the ScalaTest specs with JUnit runner inside eclipse. I think this is because of the absence of the @Test annotated methods. However if your project has Maven support, you can run your specs from command line using mvn test. For Surefire plugin to detect your specs, use the following configuration in your pom file.

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <version>2.5</version>
  <configuration>
   <includes>
    <include>**/*Spec.class</include>
   </includes>
  </configuration>
</plugin>

Check out these example for reference.

like image 44
Abhinav Sarkar Avatar answered Sep 20 '22 12:09

Abhinav Sarkar