UnitTestBot / UTBotJava

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

SBFT'24: Incorrect construction is rendered for inner class initialization in codegen #2692

Closed EgorkaKulikov closed 7 months ago

EgorkaKulikov commented 7 months ago

Consider the following tests generation

timeLimit = 120
methodFilter = "com.google.common.collect.FilteredEntryMultimap.*"
projectFilter = "guava"

Some uncompilable tests for constructors are generated. One of them looks like as follows:

@Test(expected = IllegalStateException.class)
    public void testMethodThrowsISE1() throws Exception  {
        FilteredEntryMultimap filteredEntryMultimap = ((FilteredEntryMultimap) createInstance("com.google.common.collect.FilteredEntryMultimap"));
        new Keys(filteredEntryMultimap);
    }

Seems that correct syntax is:

filteredEntryMultimap.new Keys();

May be codegen does not support such syntax. May be it supports, but it expects UtModels constructed in another way. Some investigation is required.

EgorkaKulikov commented 7 months ago

Fixed by @tepa46