JUnit in Scala category?

I did it all! I literally translated Java here in Scala line by line:

https://github.com/junit-team/junit/blob/master/doc/ReleaseNotes4.8.md

This basically meant using Array (classOf [ClassName]), deleting "public" keywords, etc. My IntelliJ IDE really helped with the suggestions.


I want to be able to run test categories, so I can mark one test class as "Version2dot3" and "SlowTest", and then be able to run only "slow tests" or run "slow tests AND 2.3" ".

I am trying to adapt this article to my Scala tests:

http://weblogs.java.net/blog/johnsmart/archive/2010/04/25/grouping-tests-using-junit-categories-0

I have a basic shell setup that almost works, but I get java.lang.Exception: No runnable methods when trying to run testSuite.

Ideas? I was able to successfully run only certain test classes using SuiteClasses, but I was not able to run test categories (@Category annotation).

 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 { } 
+4
source share
1 answer

Translate Java here in Scala line by line:

https://github.com/junit-team/junit/blob/master/doc/ReleaseNotes4.8.md

This basically means using Array (classOf [ClassName]), deleting "public" keywords, etc.

The IntelliJ smart environment with the Scala plugin helps with suggestions.

+2
source

Source: https://habr.com/ru/post/1443330/


All Articles