Skip to content

Incorrect test with ClassCastException for a function with generics in signature #2367

Open
@EgorkaKulikov

Description

@EgorkaKulikov

Description

Download the project https://github.com/SalithaUCSC/spring-boot-testing

Try to generate tests for OrderService.createOrder method with default settings.

Expected behavior

One test for this method containing one line is generated.

Actual behavior

There is a second erroneous test

@Test
    @DisplayName("createOrder: return orderRepository.save(order) : True -> ThrowClassCastException")
    public void testCreateOrder_OrderRepositorySave_1() {
        byte[] byteArray = {};
        // Order save(Order entity);
        (when(orderRepositoryMock.save(any()))).thenReturn(byteArray);
        
        /* This test fails because method [com.rest.order.services.OrderService.createOrder] produces [java.lang.ClassCastException: class] 
        orderService.createOrder(null);
    }

Additional context

Yuri strongly recommends to refactor Traverser.updateGenericTypeInfo.

Metadata

Metadata

Assignees

Labels

comp-springIssue is related to Spring projects supportcomp-symbolic-engineIssue is related to the symbolic execution enginectg-bugIssue is a bug

Type

No type

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions