-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Description
As the amount of configurable option grows, we must provide a way to merge hierarchically used options. Otherwise it would not be easily possible to refine the used options per test case.
@SnapshotTestOptions(attribute1 = nonDefaultValue, attribute2 = nonDefaultValue, attribute3 = nonDefaultValue)
class TestClass {
@Nested
@SnapshotTestOptions(attribute1 = nonDefaultValue)
class InnerTestClass {
@Test
@SnapshotTestOptions(attribute1 = defaultValue, attribute2 = nonDefaultValue)
void innerTestMethod(Snapshot snapshot) {
// actual options:
// attribute1 = defaultValue
// attribute2 = nonDefaultValue
// attribute3 = nonDefaultValue
}
}
}
Problem here is, that we need to distinguish between implicit and explicit default values.
attribute1
on the test method has an explicit default value which is intended to override a previously configured non-default value. Whereas attribute3
has an implicit default value which is not intended to override a previously configured non-default value
To be finoished:
Merging algorithm:
- Traverse the hierarchy from bottom to top, starting at the
testMethod
- Read
@SnapshotTestOptions
from current element. If non is present, useSnapshoTestOptions.DEFAULT_OPTIONS
- Read desired attribute from the obtained
SnapshotTestOptions
- If the attribute's value is not its default value, return it immediately
- If the attribute's value is its default value, continue traversing the hierarchy until a non-default value is encountered