Class TextSnapshot
- java.lang.Object
-
- de.skuzzle.test.snapshots.data.text.TextSnapshot
-
- All Implemented Interfaces:
StructuredDataProvider
@API(status=STABLE) public final class TextSnapshot extends Object implements StructuredDataProvider
Take snapshots usingObject.toString(). By default, whitespace changes of any kind will be ignored during comparison. This behavior can be changed usingwithIgnoreWhitespaces(boolean).When rendering unified diffs as String, changes in line separators are not marked at every occurrence. Instead, detected changes in line separators will result in a single informative message at the beginning of the diff.
- Author:
- Simon Taddiken
-
-
Field Summary
Fields Modifier and Type Field Description static StructuredDatatextTake Snapshots usingObject.toString()and compare the results using a generic String diff algorithm.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StructuredDatabuild()Provides theStructuredDatainstance which defines the serialization format and the way in which serialized objects are compared.static TextSnapshottext()Creates a customizableTextSnapshotinstance.TextSnapshotwithContextLines(int contextLines)Configures the amount of contextual lines that are printed around a detected change.TextSnapshotwithIgnoreWhitespaces(boolean ignoreWhitespaces)Allows to customize the whitespace comparison behavior.
-
-
-
Field Detail
-
text
public static final StructuredData text
Take Snapshots usingObject.toString()and compare the results using a generic String diff algorithm. Comparison ignores whitespace changes of any kind and does not limit the size of the unified diff.You can create a more customized text comparison by using
text()and the several customization options.- See Also:
text()
-
-
Method Detail
-
text
@API(status=STABLE, since="1.4.0") public static TextSnapshot text()Creates a customizableTextSnapshotinstance. You can also use the static constanttextwhen you want to use only defaults.- Returns:
- The customizable text snapshot
StructuredDataProvider. - Since:
- 1.4.0
-
withIgnoreWhitespaces
@API(status=STABLE, since="1.4.0") public TextSnapshot withIgnoreWhitespaces(boolean ignoreWhitespaces)Allows to customize the whitespace comparison behavior.- Parameters:
ignoreWhitespaces- Whether to ignore whitespaces during comparison.- Returns:
- This instance.
-
withContextLines
@API(status=EXPERIMENTAL, since="1.5.0") public TextSnapshot withContextLines(int contextLines)Configures the amount of contextual lines that are printed around a detected change. Per default, all lines of the full diff will be printed. If you have huge diffs with only little changes, it might be beneficial to reduce this value to a low value like 5 or 10.- Parameters:
contextLines- The amount of lines to print around a detected change in the unified diffs.- Returns:
- This instance.
- Since:
- 1.5.0
-
build
public StructuredData build()
Description copied from interface:StructuredDataProviderProvides theStructuredDatainstance which defines the serialization format and the way in which serialized objects are compared.- Specified by:
buildin interfaceStructuredDataProvider- Returns:
- The
StructuredDatainstance.
-
-