Scalatest 2.10 with akka.TestKit,奇怪的compilier错误

时间:2014-02-13 06:58:22

标签: scala scalatest

我正在使用scala IDE进行开发。我有一些我正在测试的演员。我写了一个scala测试套件,其定义如下,没有任何问题:

import org.scalatest._
import akka.testkit._
import akka.actor.ActorSystem
import org.scalatest.BeforeAndAfterAll
import org.scalatest._
import scala.concurrent.duration._
import akka.actor.Props 
import filters._

class ReaderSourceTest( _system: ActorSystem ) extends TestKit( _system ) with FunSuiteLike with BeforeAndAfterAll with ImplicitSender {
  import ReaderSource._

  //Must have a zero argument constructor
  def this() = this( ActorSystem( "ReaderSourceSuite" ) )

  override def afterAll = TestKit.shutdownActorSystem( system )

  test( "Reader should be alive as an actor" ) {
    val reader = system.actorOf( Props( classOf[ ReaderSource ], "dummy/file/name" ), "tstReaderA" )

    reader ! Ping( "Hello" )
    expectMsg( Pong( "Hello" ) )
  }
}

然后我创建了另一个测试文件来测试另一个演员:

import socketclient._
import org.scalatest._
import akka.testkit._
import akka.actor.ActorSystem
import org.scalatest.BeforeAndAfterAll
import scala.concurrent.duration._
import akka.actor.Props
import org.scalatest.fixture.FunSuiteLike
import java.net.InetAddress
import org.kdawg.CommProtocol.CommMessages._
import org.kdawg.CommProtocol.CommMessages

class NetworkTest( _system: ActorSystem ) extends TestKit( _system ) with FunSuiteLike with BeforeAndAfterAll with ImplicitSender
{
  import NetworkTalker._
  def this() = this( ActorSystem( "NetworkTalkerTest") )

  override def afterAll = TestKit.shutdownActorSystem( system )
  test( "Can Send a Packet" )
  {
     val net = system.actorOf( NetworkTalker.props("10.1.0.5", 31000), "TestA" )  
     val pktBuilder = CommMessage.newBuilder
     pktBuilder.setType( MessageType.STATUS_REQUEST )
     pktBuilder.setStatusRequest( CommProtocol.CommandsProtos.StatusRequest.newBuilder() )
     val pkt = pktBuilder.build
     net ! PktSend(1, pkt)
     expectMsg( PktSent(1) ) 
  }
}

我在上面的类的最后一行

上一直收到以下错误
Multiple markers at this line
    - type mismatch; found : org.kdawg.socketclient.NetworkTalker.PktSent required: NetworkTalkerTest.this.FixtureParam => 
     Any
    - type mismatch; found : org.kdawg.socketclient.NetworkTalker.PktSent required: NetworkTalkerTest.this.FixtureParam => 

任何人都可以帮我解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

更改导入
import org.scalatest.fixture.FunSuiteLike

import org.scalatest.FunSuiteLike

工作