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
  • Element Details

    • value

      Class<? extends Jooby> value
      Application class. Required.
      Returns:
      Application class.
    • factoryClass

      Class<?> factoryClass
      Factory class (owner of factoryMethod(). Use for create an application programmatically.
      Returns:
      Factory class or fallback for current test class.
      Default:
      java.lang.Object.class
    • factoryMethod

      String factoryMethod
      Name of factory method to create an application programmatically.
      Returns:
      Name of factory method to create an application programmatically.
      Default:
      ""
    • environment

      String environment
      Application environment, default is test.
      Returns:
      Application environment, default is test.
      Default:
      "test"
    • port

      int port
      Server port. The default port is 8911. Use 0 for random port.
      Returns:
      Server port. The default port is 8911.
      Default:
      -1
    • executionMode

      ExecutionMode executionMode
      Application execution mode. Default is ExecutionMode.DEFAULT.
      Returns:
      Application execution mode. Default is ExecutionMode.DEFAULT.
      Default:
      DEFAULT