UnitTestBot / UTBotJava

Automated unit test generation and precise code analysis for Java
Apache License 2.0
137 stars 43 forks source link

Actualise test for using except on provider with fallback #2660

Closed IlyaMuravjov closed 1 year ago

IlyaMuravjov commented 1 year ago

Description

Fixes #2659 by updating tests, that were verifying outdated semantic of except.

Previously provider.except(filter) wasn't recursive and was removing all the fallbacks.

Semantic of except was updated to solve the issues with using .except { it is ObjectValueProvider } on the following provider causing AbstractsObjectValueProvider and BuilderObjectValueProvider to be remoed (since they are fallbacks) and ObjectValueProvider itself not to be removed (since it's not on the top level, i.e. it's a part of ValueProvider.Combined that is nested into ValueProvider.Fallback that is nested into another ValueProvider.Combined).

ValueProvider.of(listOf(
    BooleanValueProvider,
    IntegerValueProvider,
    FloatValueProvider,
    StringValueProvider,
    NumberValueProvider,
    anyObjectValueProvider(idGenerator),
    ArrayValueProvider(idGenerator),
    EnumValueProvider(idGenerator),
    ListSetValueProvider(idGenerator),
    MapValueProvider(idGenerator),
    IteratorValueProvider(idGenerator),
    EmptyCollectionValueProvider(idGenerator),
    DateValueProvider(idGenerator),
    (ObjectValueProvider(idGenerator)
        with ArrayValueProvider(idGenerator)
        with EnumValueProvider(idGenerator)
        with ListSetValueProvider(idGenerator)
        with MapValueProvider(idGenerator)
        with IteratorValueProvider(idGenerator)
        with EmptyCollectionValueProvider(idGenerator)
        with DateValueProvider(idGenerator))
            .withFallback(
                AbstractsObjectValueProvider(idGenerator)
                        with BuilderObjectValueProvider(idGenerator)
            ),
    VoidValueProvider,
    NullValueProvider,
))

How to test

Automated tests

The proposed changes are verified with tests: utbot-fuzzing/src/test/kotlin/org/utbot/fuzzing/ProvidersTest.kt

Self-check list