Inlining Variables

Inlining changes the appearance of tests by removing the separate variables for the return value of the function under test and any parameters for the method call.

Open the IntelliJ IDEA -> Preferences (macOS) or File -> Settings (Windows/Linux) menu and navigate to the Diffblue Cover option under the Tools section. Under the Generation tab, it is possible to set a number of options which control the inlining behavior of Diffblue Cover:

Inline immediate values: Allows inlining of immediate values (primitive or string literals).

Inline chaining member accesses: Allows inlining of member access expressions, even if they result in a chaining expression of member accesses.

Inline "arrange" into "act" or "assert": Allows inlining of expressions from the "Arrange" section of tests into the "Act" or "Assert" section.

Inline "act" into "assert": Allows inlining expressions from the "Act" section of tests into the "Assert" section.

Inline constructor invocations into method invocations: Allows inlining of constructor invocations into method invocation expressions, forming an expression chain.

Example:

When Inline "act" into "assert" is not set, the tests generated will look like this:

@Test
public void testhasItem() throws Exception {
  // Arrange
  Order order = new Order();

  // Act
  boolean actual = order.hasItem();

  // Assert
  assertFalse(actual);
}

When Inline "act" into "assert" is set, the tests generated will look like this:

@Test
public void testhasItem() throws Exception {
  // Arrange
  Order order = new Order();

  // Act and Assert
  assertFalse(order.hasItem());
}

results matching ""

    No results matching ""