Last active
December 18, 2015 18:19
-
-
Save jbellenger/5824938 to your computer and use it in GitHub Desktop.
The goal here is to create an entire akka ActorSystem for each test case with minimum boilerplate required for each test.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.junit.runner.RunWith | |
import org.scalatest.junit.JUnitRunner | |
import org.scalatest.FunSuite | |
import akka.actor._ | |
import akka.actor.Actor.emptyBehavior | |
import akka.testkit.{TestKit, ImplicitSender} | |
class DummyActor extends Actor { | |
val receive = emptyBehavior | |
} | |
abstract class ActorTestCase extends TestKit(ActorSystem("per-test-actorsystem")) with ImplicitSender | |
@RunWith(classOf[JUnitRunner]) | |
class DummyTest extends FunSuite { | |
// can this syntax be simplified to implicitly create an ActorTestCase with a constructor provided here? | |
test("foo") ( | |
new ActorTestCase { | |
// system provided by TestKit | |
val ref = system.actorOf(Props[DummyActor], "mydummy") | |
// assert and === provided by FunSuite | |
assert(ref.isTerminated === false) | |
} | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment