下面是一个使用TestKit测试带参数的消息的示例代码:
import akka.actor.{Actor, ActorSystem, Props}
import akka.testkit.{TestKit, TestProbe}
import org.scalatest.BeforeAndAfterAll
import org.scalatest.wordspec.AnyWordSpecLike
class MyActor extends Actor {
  def receive: Receive = {
    case msg: String =>
      sender() ! s"Received message: $msg"
  }
}
class MyActorSpec extends TestKit(ActorSystem("MyActorSpec"))
  with AnyWordSpecLike with BeforeAndAfterAll {
  override def afterAll(): Unit = {
    TestKit.shutdownActorSystem(system)
  }
  "MyActor" should {
    "return a response with the message" in {
      val testProbe = TestProbe()
      val myActor = system.actorOf(Props[MyActor])
      myActor.tell("Hello", testProbe.ref)
      testProbe.expectMsg("Received message: Hello")
    }
  }
}
在这个示例中,我们定义了一个名为MyActor的Actor,它接收一个字符串消息,并将带有消息的响应发送回发送者。
在测试类MyActorSpec中,我们继承了TestKit和AnyWordSpecLike,并在afterAll方法中关闭了ActorSystem。在测试方法中,我们使用TestProbe来模拟发送者,并创建了一个MyActor的实例。
然后,我们使用tell方法将一条消息发送给MyActor,并使用expectMsg方法来检查发送者是否收到了正确的响应消息。
请注意,这里的示例代码是使用Scala语言编写的Akka测试,所以您需要在项目中引入相关的依赖。