Skip to content

Unexpected tests for some inherited methods on enums #457

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

Closed
sofurihafe opened this issue Jul 8, 2022 · 3 comments · Fixed by #505
Closed

Unexpected tests for some inherited methods on enums #457

sofurihafe opened this issue Jul 8, 2022 · 3 comments · Fixed by #505
Assignees
Labels
comp-symbolic-engine Issue is related to the symbolic execution engine ctg-bug Issue is a bug

Comments

@sofurihafe
Copy link
Member

Description

Generated tests for enum contain methods testing valueOf

To Reproduce

  1. Run Contest Estimator with method com.google.common.base.CaseFormat.* and 300s time limit.

Actual behavior

Generated tests contain the following:

    @Test
    //@org.junit.jupiter.api.DisplayName("valueOf: arg_0 = blank string -> throw IllegalArgumentException")
    public void testValueOfThrowsIAEWithBlankString() {
        /* This test fails because executable under testing com.google.common.base.CaseFormat.valueOf
        produces Runtime exception java.lang.IllegalArgumentException: No enum constant com.google.common.base.CaseFormat.    */
        CaseFormat.valueOf("   ");
    }

    @Test
    //@org.junit.jupiter.api.DisplayName("valueOf: arg_0 has special characters -> throw IllegalArgumentException")
    public void testValueOfThrowsIAEWithBlankString1() {
        /* This test fails because executable under testing com.google.common.base.CaseFormat.valueOf
        produces Runtime exception java.lang.IllegalArgumentException: No enum constant com.google.common.base.CaseFormat.
	
 */
        CaseFormat.valueOf("\n\t\r");
    }
@sofurihafe sofurihafe added ctg-bug Issue is a bug comp-symbolic-engine Issue is related to the symbolic execution engine labels Jul 8, 2022
@sofurihafe sofurihafe moved this to Todo in UTBot Java Jul 8, 2022
@EgorkaKulikov
Copy link
Collaborator

This behaviour can also be reproduced on equals and hashCode methods.

@EgorkaKulikov EgorkaKulikov changed the title Unexpected tests for valueOf on enums Unexpected tests for some inherited methods on enums Jul 8, 2022
@dtim
Copy link
Collaborator

dtim commented Jul 8, 2022

It seems that tests for Enum::valueOf(String) and Enum::values() are correct by themselves: these methods are not inherited but generated by the compiler as a part of a specific enum class. At the same time they are redundant, as they test the generated code on that users do not have any control.

@dtim
Copy link
Collaborator

dtim commented Jul 12, 2022

My opinion: we should generate tests for overridden hashCode, equals, toString etc (including anonymous classes), but not to generate tests for inherited methods where no user-defined implementation is present in the class under test.

TODO: check if tests are generated for inherited methods without user-defined implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp-symbolic-engine Issue is related to the symbolic execution engine ctg-bug Issue is a bug
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants