Annotation Type SnapshotTestOptions


  • @API(status=EXPERIMENTAL,
         since="1.7.0")
    @Target({TYPE,METHOD})
    @Retention(RUNTIME)
    public @interface SnapshotTestOptions
    Allows to configure some behavior details of the snapshot testing engine. This annotation can either be placed on the test class itself or on single test methods. Annotations on test methods take precedence over the one on the test class. If the annotation is not specified at all, the documented defaults apply.

    If you want to globally modify the snapshot directory, see the SnapshotDirectory annotation.

    Since:
    1.7.0
    • Field Detail

      • DEFAULT_CONTEXT_LINES

        static final int DEFAULT_CONTEXT_LINES
        Default number of context lines that are displayed in diffs.
    • Element Detail

      • textDiffContextLines

        int textDiffContextLines
        Defines the number of context lines that are printed around a comparison failure. Note that this setting only applies to unified diffs created for structural comparisons. If you use text comparison, then you must control the amount of context lines using TextSnapshot.withContextLines(int).

        Defaults to 5.

        Returns:
        The number of context lines to print in unified diffs within our structural assertion failures.
        See Also:
        TextSnapshot.withContextLines(int)
        Default:
        5
      • renderLineNumbers

        @API(status=EXPERIMENTAL,
             since="1.7.1")
        SnapshotTestOptions.DiffLineNumbers renderLineNumbers
        Controls whether an offset is added to the line numbers that are displayed when rendering diffs. You can choose to render line numbers according to the original raw test result or according to the physical lines in the persisted snapshot files. The latter includes some header information at the beginning of the file which add an offset to the actual data lines.

        Defaults to SnapshotTestOptions.DiffLineNumbers.ACCODRDING_TO_PERSISTED_SNAPSHOT_FILE.

        Returns:
        How to calculate line numbers in rendered diffs.
        Since:
        1.7.1
        Default:
        de.skuzzle.test.snapshots.SnapshotTestOptions.DiffLineNumbers.ACCODRDING_TO_PERSISTED_SNAPSHOT_FILE
      • alwaysPersistActualResult

        boolean alwaysPersistActualResult
        Whether to always persist the latest actual test result in a parallel file next to the .snapshot file. The actual result will be persisted in a file with identical name but with .snapshot_actual file extension.

        Note: If you opt into enabling this option, you should add the .snapshot_actual to your .gitignore file. Other than the normal .snapshot files, the ..._actual files are not intended to be checked into the SCM.

        If this option is disabled, then all existing ..._actual files will be proactively deleted by the framework during test execution.

        Defaults to false.

        Returns:
        Whether to always persist the latest actual test result.
        Default:
        false
      • alwaysPersistRawResult

        boolean alwaysPersistRawResult
        When enabled, the framework will persist the raw actual result without snapshot header as a sibling file to the real .snapshot file with the extension .snapshot_raw.

        Note: If you opt into enabling this option, you should add the .snapshot_actual to your .gitignore file. Other than the normal .snapshot files, the ..._raw files are not intended to be checked into the SCM.

        If this option is disabled, then all existing ..._raw files will be proactively deleted by the framework during test execution.

        Defaults to false.

        Returns:
        Whether to additionally persist the raw snapshot results.
        Default:
        false
      • normalizeLineEndings

        @API(since="1.10.0",
             status=EXPERIMENTAL)
        SnapshotTestOptions.NormalizeLineEndings normalizeLineEndings
        Advises the framework to convert the line endings after snapshot serialization to the given value.

        By default, line endings are not normalized but when using GIT it is advisable to set this to SnapshotTestOptions.NormalizeLineEndings.GIT

        Returns:
        How to normalize line endings.
        Since:
        1.10.0
        Default:
        de.skuzzle.test.snapshots.SnapshotTestOptions.NormalizeLineEndings.NEVER