Skip to content

Allow Fuzzer use all class under test public methods #2444

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Aug 11, 2023

Conversation

sofurihafe
Copy link
Member

@sofurihafe sofurihafe commented Jul 25, 2023

Description

Fixes #2344

How to test

Automated tests

Not relevant.

Manual tests

  1. Generate a unit test with 100% fuzzer setting for the mut method:
class SampleClass {
    private int someField = 0;

    public int getSomeField() {
        return someField;
    }

    public void randomMethod1() {
        this.someField = 42;
        int[] array = {0};
        this.someField = array[10];
    }

    public int mut() {
        if (this.someField == 42) return 0;
        else if (this.someField == 0) return 1;
        else return 2;
    }
}

Generated test will have randomMethod1() being called and wrapped in try-catch block.

public final class SampleClassTest {
    ///region Test suites for executable SampleClass.mut

    ///region FUZZER: SUCCESSFUL EXECUTIONS for method mut()

    <...>

    @Test
    public void testMutReturnsZero() {
        SampleClass sampleClass = new SampleClass();
        try {
            sampleClass.randomMethod1();
        } catch (ArrayIndexOutOfBoundsException arrayIndexOutOfBoundsException) {}

        int actual = sampleClass.mut();

        assertEquals(0, actual);
    }
    ///endregion

    ///endregion
}

@sofurihafe sofurihafe added ctg-enhancement New feature, improvement or change request comp-fuzzing Issue is related to the fuzzing labels Jul 25, 2023
@sofurihafe sofurihafe force-pushed the andrey-t/fuzzer_mutations branch from 7a6678e to e0ad607 Compare July 25, 2023 14:39
@sofurihafe sofurihafe force-pushed the andrey-t/fuzzer_mutations branch from e0ad607 to 61da8f1 Compare July 26, 2023 15:28
@sofurihafe sofurihafe force-pushed the andrey-t/fuzzer_mutations branch 2 times, most recently from e25b2d1 to d76cae0 Compare July 30, 2023 13:54
@sofurihafe sofurihafe force-pushed the andrey-t/fuzzer_mutations branch from d76cae0 to 8a90b7d Compare August 8, 2023 17:35
@EgorkaKulikov EgorkaKulikov marked this pull request as ready for review August 9, 2023 11:47
@EgorkaKulikov EgorkaKulikov merged commit 19ab8f5 into main Aug 11, 2023
@EgorkaKulikov EgorkaKulikov deleted the andrey-t/fuzzer_mutations branch August 11, 2023 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp-fuzzing Issue is related to the fuzzing ctg-enhancement New feature, improvement or change request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support more mutations in Spring fuzzing
2 participants