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
- Alphabetic
- By Inheritance
- ServiceTest
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
bind[T](clazz: Class[T]): BindingKey[T]
Create a binding that can be used with the
GuiceApplicationBuilderin theSetup, e.g.Create a binding that can be used with the
GuiceApplicationBuilderin theSetup, e.g. to override bindings to stub out dependencies to other services. -
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
val
defaultSetup: Setup
The default
Setupconfiguration, which has persistence enabled. -
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
eventually(max: FiniteDuration, interval: FiniteDuration, block: Effect): Unit
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. Theblockis retried with the giveninterval. -
def
eventually(max: FiniteDuration, block: Effect): Unit
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. Theblockis retried with 100 milliseconds interval. -
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
def
startServer(setup: Setup): TestServer
Start the test server with the given
setup.Start the test server with the given
setup. You must stop the server with thestopmethod of the returnedTestServerwhen 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
@BeforeClassand stop it in a method annotated with@AfterClass. Otherwise #withServer is more convenient.You can get the service client from the returned
TestServer. -
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
def
withServer(setup: Setup, block: Procedure[TestServer]): Unit
Start the test server with the given
setupand run theblock(lambda).Start the test server with the given
setupand run theblock(lambda). When theblockreturns 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
TestServerthat is passed as parameter to theblock.