Object

com.lightbend.lagom.javadsl.testkit

ServiceTest

Related Doc: package testkit

Permalink

object ServiceTest

Support for writing functional tests for one service. The service is running in a server and in the test you can interact with it using its service client, i.e. calls to the service API.

Dependencies to other services must be replaced by stub or mock implementations by overriding the bindings of the GuiceApplicationBuilder in the Setup.

The server is ran standalone without persistence, pubsub or cluster features enabled. Cassandra is also disabled by default. If your service require either of these features you can enable them in the Setup.

There are two different styles that can be used. It is most convenient to use withServer, since it automatically starts and stops the server before and after the given lambda. When your test have several test methods, and especially when using persistence, it is faster to only start the server once in a static method annotated with @BeforeClass and stop it in a method annotated with @AfterClass.

Source
ServiceTest.scala
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ServiceTest
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. sealed trait Setup extends AnyRef

    Permalink
  2. class TestServer extends AnyRef

    Permalink

    When the server is started you can get the service client and other Guice bindings here.

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def bind[T](clazz: Class[T]): BindingKey[T]

    Permalink

    Create a binding that can be used with the GuiceApplicationBuilder in the Setup, e.g.

    Create a binding that can be used with the GuiceApplicationBuilder in the Setup, e.g. to override bindings to stub out dependencies to other services.

  6. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  7. val defaultSetup: Setup

    Permalink

    The default Setup configuration, which has persistence enabled.

  8. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  9. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  10. def eventually(max: FiniteDuration, interval: FiniteDuration, block: Effect): Unit

    Permalink

    Retry the give block (lambda) until it does not throw an exception or the timeout expires, whichever comes first.

    Retry the give block (lambda) until it does not throw an exception or the timeout expires, whichever comes first. If the timeout expires the last exception is thrown. The block is retried with the given interval.

  11. def eventually(max: FiniteDuration, block: Effect): Unit

    Permalink

    Retry the give block (lambda) until it does not throw an exception or the timeout expires, whichever comes first.

    Retry the give block (lambda) until it does not throw an exception or the timeout expires, whichever comes first. If the timeout expires the last exception is thrown. The block is retried with 100 milliseconds interval.

  12. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  13. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  14. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  15. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  16. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  17. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  18. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  19. def startServer(setup: Setup): TestServer

    Permalink

    Start the test server with the given setup.

    Start the test server with the given setup. You must stop the server with the stop method of the returned TestServer when the test is finished.

    When your test have several test methods, and especially when using persistence, it is faster to only start the server once in a static method annotated with @BeforeClass and stop it in a method annotated with @AfterClass. Otherwise #withServer is more convenient.

    You can get the service client from the returned TestServer.

  20. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  21. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  22. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  23. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  24. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  25. def withServer(setup: Setup, block: Procedure[TestServer]): Unit

    Permalink

    Start the test server with the given setup and run the block (lambda).

    Start the test server with the given setup and run the block (lambda). When the block returns or throws the test server will automatically be stopped.

    This method should be used when the server can be started and stopped for each test method. When your test have several test methods, and especially when using persistence, it is faster to only start the server once with #startServer.

    You can get the service client from the TestServer that is passed as parameter to the block.

Inherited from AnyRef

Inherited from Any

Ungrouped