Annotation Type TestResource


  • @ExtendWith(com.github.robtimus.junit.support.extension.testresource.TestResourceExtension.class)
    @Target({FIELD,PARAMETER,ANNOTATION_TYPE})
    @Retention(RUNTIME)
    public @interface TestResource
    TestResource can be used to annotate a field or a parameter in a lifecycle method or test method that should be resolved into the contents of a (test) resource. The resource will be loaded relative to the class where the field, constructor or method is defined. The following field / parameter types are supported by default:
    • String
    • CharSequence
    • StringBuilder
    • byte[]
    When the type is not byte[], Encoding can be used to change the encoding to use (defaults to UTF-8).

    In addition, LoadWith can be used to specify a method that is used to load the contents of the resource into an object, or EOL can be used to define the line separator to use for String, CharSequence and StringBuilder. This can be useful to create tests that work on different operating systems. It is illegal to:

    Author:
    Rob Spoor
    Since:
    2.0
    • Required Element Summary

      Required Elements 
      Modifier and Type Required Element Description
      String value
      The resource to load.
    • Element Detail

      • value

        String value
        The resource to load.