Annotation 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
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    Whether or not the arguments should be formatted to string using JGiven formatter.
    A custom implementation of the CaseAsProvider to provide a case description.
    The description of the test case.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Dummy value to indicate that no value was set
  • Field Details

  • Element Details

    • value

      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

      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