Oliver Shaw
Oliver Shaw

Reputation: 5412

Behaviour within SBT vs launching SBT

I'm having an issue where a particular tests fails using test-only within an sbt session, e.g

sbt
> test-only package.Test

where as running as a single command works fine. E.g

sbt 'test-only package.Test'

I wonder why the behaviour would be different?

I'm still working on a minimum example that I hope to share.

Update: This appears to be linked to instantiation of a Akka actor system. The error is boiling down to.

interface akka.actor.Scheduler is not assignable from class akka.actor.LightArrayRevolverScheduler

Upvotes: 0

Views: 34

Answers (1)

Oliver Shaw
Oliver Shaw

Reputation: 5412

So this boiled down to a mis-use of actor systems.

The dodgy code boiled down to something like this as a mock withing a test

class FooSpec extends UnitSpec {
...
    val controller = new FooController {
      override lazy val actorSystem = ActorSystem("test")
    }
...
}

The correct way to do it was to use akka-testkit

class FooSpec extends TestKit(ActorSystem("test")) with UnitSpec {
...
    val controller = new FooController {
      override lazy val actorSystem = system
    }
...
}

Now the thing works everytime no matter how I envoke sbt.

Upvotes: 1

Related Questions