Package io.jooby.test
Annotation Interface JoobyTest
@Target({TYPE,METHOD})
@Retention(RUNTIME)
@Test
@ExtendWith(JoobyExtension.class)
public @interface JoobyTest
Startup Jooby applications using JUnit extension mechanism.
When this annotation is set at class level, a single jooby application is started:
@JoobyTest(MyApp.class)
public class MyTest {
@Test
public void test() {
Use your favorite HTTP client and call Jooby.
}
}
When this annotation is set at method level, a jooby application is started per test/method:
public class MyTest {
@JoobyTest(MyApp.class)
public void test() {
Use your favorite HTTP client and call Jooby.
}
@JoobyTest(MyApp.class)
public void anotherTest() {
Use your favorite HTTP client and call Jooby.
}
}
Server path and port can be injected as instance fields or method parameters:
@JoobyTest(MyApp.class)
public MyTest {
public String serverPath;
public void test() {
Use your favorite HTTP client and call Jooby.
}
}
public MyTest {
@JoobyTest(MyApp.class)
public void test(String serverPath) {
Use your favorite HTTP client and call Jooby.
}
}
- Since:
- 2.0.0
- Author:
- edgar
-
Required Element Summary
Required Elements -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionApplication environment, default istest.io.jooby.ExecutionModeApplication execution mode.Class<?> Factory class (owner offactoryMethod().Name of factory method to create an application programmatically.intServer port.
-
Element Details
-
value
Class<? extends io.jooby.Jooby> valueApplication class. Required.- Returns:
- Application class.
-
factoryClass
Class<?> factoryClassFactory class (owner offactoryMethod(). Use for create an application programmatically.- Returns:
- Factory class or fallback for current test class.
- Default:
java.lang.Object.class
-
factoryMethod
String factoryMethodName of factory method to create an application programmatically.- Returns:
- Name of factory method to create an application programmatically.
- Default:
""
-
environment
String environmentApplication environment, default istest.- Returns:
- Application environment, default is
test.
- Default:
"test"
-
port
int portServer port. The default port is8911. Use0for random port.- Returns:
- Server port. The default port is
8911.
- Default:
-1
-
executionMode
io.jooby.ExecutionMode executionModeApplication execution mode. Default isExecutionMode.DEFAULT.- Returns:
- Application execution mode. Default is
ExecutionMode.DEFAULT.
- Default:
DEFAULT
-