Skip to content

Inaccurate test naming for methods of nested classes #560

Closed
@volivan239

Description

@volivan239

Description

Tests generated for methods of nested classes has the same names as if they were methods of enclosing class.

To Reproduce

Launch contest estimator with projectFilter = null, methodFilter = "com.google.common.base.CaseFormat.*" and timeLimit = 120. Look at tests generated for CaseFormat.StringConverter.equals

Expected behavior

Tests should be named something like testStringConverterEqualsReturnsFalse (or some other way to explicitly show that these are tests not for CaseFormat.equals but for CaseFormat.StringConverter.equals)

Actual behavior

Tests are named like testEqualsReturnsFalse

Visual proofs (screenshots, logs, images)

From generated testFile:

@Test
//@org.junit.jupiter.api.DisplayName("equals: object = Object() -> return false")
public void testEqualsReturnsFalse() throws Exception  {
    Object stringConverter = createInstance("com.google.common.base.CaseFormat$StringConverter");
    Object object = new Object();
    
    Class stringConverterClazz = Class.forName("com.google.common.base.CaseFormat$StringConverter");
    Class objectType = Class.forName("java.lang.Object");
    Method equalsMethod = stringConverterClazz.getDeclaredMethod("equals", objectType);
    equalsMethod.setAccessible(true);
    java.lang.Object[] equalsMethodArguments = new java.lang.Object[1];
    equalsMethodArguments[0] = object;
    boolean actual = ((Boolean) equalsMethod.invoke(stringConverter, equalsMethodArguments));
    
    assertFalse(actual);
}

Environment

Contest estimator, Java11

Metadata

Metadata

Assignees

Labels

comp-codegenIssue is related to code generatorcomp-summariesSomething related to the method names, code comments and display names generationctg-enhancementNew feature, improvement or change request

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions