7
votes

Problem: I cannot setup Run Configurations to run scalatest for the Scalatests in my project.

Steps to reproduce:

  • Right click on Scala Suite and click on Run as -> Run configurations..
  • On the left, I see a configuration template for ScalaTest. I click on New and fill the Name but it cannot find the suite-class.

Note: It is mentioned here that I should see Run as -> ScalaTest - Suite but I do not see that option. I tried using context menu in the editor, and in the package explorer

Steps taken:

  • Using: Scala IDE for Eclipse version: 2.1.0.m3-2_09
  • Using SBT, assemble project, run eclipse command and then import project and dependencies into Eclipse
  • Project compiles. ScalaTest code compiles(scalatest_2.9.2-1.8.jar is in the 'Referenced Libraries' configuration)
6
Just a quick thought... do you maybe have an object defined but the runner needs a class?user500592
@asflierl: Nope,it is a class extending FunSuiteRAbraham
OK :-/ one more idea: is your test class in the default package? I can reproduce your case when I remove the package declaration from the top of a test class source file.user500592
:(. No, the test class has a package declaration. package spark.bagel. Thanks for taking the time to help me :).RAbraham
Another possible solution to this problem comes from @krzysiek-novak, in which he suggests adding a Run Configuration for the project, with type "Suite", and specifying "package.*" as the suite class, where package is a top level package from which you wish the discovery of tests to start.Pepe Mandioca

6 Answers

8
votes

I've been fighting a similar problem for the past few days; Lily / Jimbo's answer didn't quite match my situation, but helped me find the right direction.

In my case, I was using a third-party library that I'd copied in. The package names of the classes and tests matched, but the folder structure did not -- all of my tests were directly in Play's "/test" folder, rather than in folders that matched the package names. This didn't show any errors, but was broken: packages ought to match folders. When I built the right folder structure underneath test, and recompiled, the expected "Run As -> ScalaTest - Suite" options showed up.

Don't know if your problem is the same, but you might check this if you haven't already found the issue...

1
votes

This could be caused by a misalignment between the scalatest and the scala eclipse IDE version. Try scalatest_2.9.0-2.0.M5b.jar or scalatest_2.10-2.0.M5b.jar. The former jar definitely works with ide 2.0.9.x so maybe the new version needs the 2.10 jar. Pick your version carefully from here

1
votes

Willem's answer is what worked for me. Getting both plugins from the same update site (from the list on Scalatest's github site), seemed to work for me using Kepler.

1
votes

for my case, one click on 'Reimport All Maven Projects' icon, like 'Refresh' icon, solved the problem.

0
votes

Not sure if you fixed the error, but I had similar a error yesterday and was pulling my hair trying to fix it (none of the suggestions I found by googling seemed to help me). So for me, it turns out that it's as easy as package hierarchy in my test suite.

I am using the play framework, so naturally my folders look like this controllers.package1.package2.... and this applies to my test folders also.

Now my test classes however, have the package definition package1.package2..... (no "controllers" as prefix).

If I run the tests on sbt/play command prompt, it's not a problem. But running them through Eclipse would give me the problem you described.

So anyways... thought I'd share this, in case this could help.

0
votes

it's a bit annoying combined with the view template compile issue in play framework. but my approach is to regenerate the eclipse project file and add view template path into the class path