Search code examples
eclipsescalascalatestscala-ide

eclipse does not treat a scalatest flatspec as junit test


here is my test case , while i right click the file eclipse doest not show any run as junit test option. I try to manual create run configuration but does not take any sense. scala version:2.8.1 scalatest:1.3 eclipse:3.6.2

package org.jilen.cache.segment

import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import org.scalatest.FlatSpec
import org.scalatest.matchers.ShouldMatchers

@RunWith(classOf[JUnitRunner])
class RandomSegmentSpec extends FlatSpec with ShouldMatchers {
  val option = SegmentOptions()

  "A Simple Segment" should "contains (douglas,lea) after put into" in {
    val segment = RandomSegment.newSegment(option)
    segment.put("douglas", "lea")
    segment("douglas") should be("lea")
  }
  it should "return null after (douglas,lea) is remove" in {
    val segment = RandomSegment.newSegment(option)
    segment.put("douglas", "lea")
    segment -= ("douglas")
    segment("douglas") should equal(null)
  }

  it should "contains nothing after clear" in {
    val segment = RandomSegment.newSegment(option)
    segment.put("jilen", "zhang")
    segment.put(10, "ten")
    segment += ("douglas" -> "lea")
    segment += ("20" -> 20)
    segment.clear()
    segment.isEmpty should be(true)
  }
}

Solution

  • This is a known problem with the Eclipse IDE for Scala. I'm currently working on the plugin for this. Watch this space.