Note that there are some explanatory texts on larger screens.

plurals
  1. POJUnit test categories in Scala?
    text
    copied!<p>I got it working! I literally translated the Java here into Scala line by line:</p> <p><a href="https://github.com/junit-team/junit/blob/master/doc/ReleaseNotes4.8.md" rel="nofollow">https://github.com/junit-team/junit/blob/master/doc/ReleaseNotes4.8.md</a></p> <p>Mostly it meant doing Array(classOf[ClassName]), removing "public" keywords, etc. My IntelliJ IDE helped a lot with suggestions.</p> <hr> <p>I want to be able to run categories of tests, so I might tag one class of tests as "Version2dot3" and "SlowTest" and then be able to run just "slow tests", or run "slow tests AND 2.3 tests".</p> <p>I've been trying to adapt this article to my Scala tests:</p> <p><a href="http://weblogs.java.net/blog/johnsmart/archive/2010/04/25/grouping-tests-using-junit-categories-0" rel="nofollow">http://weblogs.java.net/blog/johnsmart/archive/2010/04/25/grouping-tests-using-junit-categories-0</a></p> <p>I have a basic shell setup that almost works, but I'm getting <code>java.lang.Exception: No runnable methods</code> errors when I try to run the testSuite.</p> <p>Ideas? I've successfully been able to run only certain test classes with SuiteClasses, but have not been able to run categories of tests (@Category annotation).</p> <pre><code>import org.junit.experimental.categories.{Categories, Category} import org.junit.runners.Suite.SuiteClasses import org.scalatest.FunSuite import org.junit.runner.RunWith import org.scalatest.junit.JUnitRunner @RunWith(classOf[JUnitRunner]) @Category(Array(classOf[SlowTests])) class FunSuiteTest extends FunSuite with DemoHelpers { test("demoTest1") { println("\n\nrunning DemoTest1...\n\n") } } @RunWith(classOf[JUnitRunner]) @Category(Array(classOf[SlowTests])) class FunSuiteTest2 extends FunSuite with DemoHelpers { test("demoTest2") { println("\n\nrunning DemoTest2...\n\n") } } @RunWith(classOf[Categories]) @SuiteClasses(Array(classOf[SlowTests])) class testSuite { } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload