Annotation Type CaseAs


  • @Documented
    @Inherited
    @Retention(RUNTIME)
    @Target({METHOD,TYPE})
    public @interface CaseAs
    Use to define a description provider for scenario cases.

    By default, multiple cases in a parametrized scenario are described by just listing the parameter names with their corresponding values. Sometimes, however, it is useful to provide an explicit description the provides more semantic background for each case. This annotation can be used to define custom descriptions. The enumeration of arguments starts from index 1.

    Since:
    v0.16.0
    • Field Summary

      Fields 
      Modifier and Type Fields Description
      static java.lang.String NO_VALUE
      Dummy value to indicate that no value was set
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      boolean formatValues
      Whether or not the arguments should be formatted to string using JGiven formatter.
      java.lang.Class<? extends CaseAsProvider> provider
      A custom implementation of the CaseAsProvider to provide a case description.
      java.lang.String value
      The description of the test case.
    • Field Detail

      • NO_VALUE

        static final java.lang.String NO_VALUE
        Dummy value to indicate that no value was set
    • Element Detail

      • value

        java.lang.String value
        The description of the test case.

        Placeholders of the form $i can be used that will be filled with the values of the ith parameter, starting from 1.

        For example, a value "Hi $1" will be translated to "Hi JGiven" if "JGiven" is the value of the first parameter of the test method.

        Default:
        " - no value - "
      • provider

        java.lang.Class<? extends CaseAsProvider> provider
        A custom implementation of the CaseAsProvider to provide a case description.
        Default:
        com.tngtech.jgiven.impl.params.DefaultCaseAsProvider.class
      • formatValues

        boolean formatValues
        Whether or not the arguments should be formatted to string using JGiven formatter. If this is set to true the list of parameter values passed to the CaseDescriptionProvider will be a list of strings, otherwise it will be a list of objects with the original values passed to the method.
        Default:
        true