Skip to content

Provide a way to merge @SnapshotTestOptions #101

@skuzzle

Description

@skuzzle

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:

  1. Traverse the hierarchy from bottom to top, starting at the testMethod
  2. Read @SnapshotTestOptions from current element. If non is present, use SnapshoTestOptions.DEFAULT_OPTIONS
  3. Read desired attribute from the obtained SnapshotTestOptions
  4. If the attribute's value is not its default value, return it immediately
  5. If the attribute's value is its default value, continue traversing the hierarchy until a non-default value is encountered

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions