Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fuzzing Spring class with protected default constructor leads to compilation error #2559

Open
Assignees
Labels
comp-codegenIssue is related to code generator comp-springIssue is related to Spring projects support ctg-bugIssue is a bug
@EgorkaKulikov

Description

Description

Consider generating integration tests with application configuration from spring-boot-testing for the method

public boolean isNotEmpty() {
 List<Order> orders = orderRepository.findAll();
 return orders.size() > 0;
 }

where Order has the following constructors:

protected Order() {}
public Order(Long id, String buyer, int price, int qty) {
 this.id = id;
 this.buyer = buyer;
 this.price = price;
 this.qty = qty;
}

Expected behaviour

Generated tests can be successfully compiled and run.

Actual behaviour

The following uncompilable test is generated. The problem is in line with order1 definition.

@Test
@DisplayName("isNotEmpty: -> return true")
public void testIsNotEmptyReturnsTrue() throws InstantiationException, IllegalAccessException, InvocationTargetException {
 Object[] orderConstructorArguments1 = new Object[0];
 Order order1 = ((Order) orderConstructor.newInstance(orderConstructorArguments1));
 entityManager1.persist(order1);
 entityManager1.flush();
 boolean actual = orderService.isNotEmpty();
 assertTrue(actual);
}

Metadata

Metadata

Labels

comp-codegenIssue is related to code generator comp-springIssue is related to Spring projects support ctg-bugIssue is a bug

Type

No type

Projects

Status

Todo

Milestone

No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      AltStyle によって変換されたページ (->オリジナル) /