Plugin configuration

Now that our project is set up and ready to go, we need to configure the plugin. Open thePreferences(orSettings) menu and navigate to theDiffblue Coveroption under theToolssection.

Connection

Under the Connection tab, the host address should be set to the location of the Diffblue Cover instance. Enter the address in the formhttp://cover.example.comor https://127.0.0.1.

Generation

Under the Generation tab, it is possible to select options to Inline Variables and/or Hide Comments.

Inline Variables

Inlining changes the appearance of the tests by removing the separate variables passed to the method under test.

This option sets two underlying analysis options:

inlineFunctionArguments: function arguments that are primitive, boxed primitive, string or null value, are inlined into the call to the method under test.

inlineIntoAssertion: the call to an accessible method under test that returns a primitive, boxed primitive, string or null value, is inlined into the assertion.

When Inline Variables is set, the tests generated will look like this:

// Test written by Diffblue Cover.
@Test
public void greaterThanFiveTenTimesInputZeroOutputFalse() {

  // Arrange
  final Simple simple = new Simple();

  // Act and Assert result
  Assert.assertFalse(simple.greaterThanFiveTenTimes(0));

}

When Inline Variables isn't set, the tests generated will look like this:

// Test written by Diffblue Cover.
@Test
public void greaterThanFiveTenTimesInputZeroOutputFalse() {

  // Arrange
  final Simple simple = new Simple();
  final int value = 0;

  // Act
  final boolean actual = simple.greaterThanFiveTenTimes(value);

  // Assert result
  Assert.assertFalse(actual);

}

Hide Comments

Setting the Hide Comments option prevents comments from being added to the generated tests. By default, comments will be added describing the different sections of each test.

If Hide Comments is not selected, the tests generated will look like this:

// Test written by Diffblue Cover.
@Test
public void greaterThanFiveTenTimesInputZeroOutputFalse() {

  // Arrange
  final Simple simple = new Simple();

  // Act and Assert result
  Assert.assertFalse(simple.greaterThanFiveTenTimes(0));

}

With both Inline Variables and Hide Comments selected, the tests generated might look like this:

@Test
public void greaterThanFiveTenTimesInputZeroOutputFalse() {
  final Simple simple = new Simple();
  Assert.assertFalse(simple.greaterThanFiveTenTimes(0));
}

Coverage

Under the Coverage tab, it is possible to choose the colors used to denote whether lines have been covered as follows:

  • New lines that are now covered by Diffblue Cover unit tests. These lines are marked with a blue dot by default.
  • Existing lines that were previously covered by existing unit tests. These lines are marked with a green dot by default.
  • Missing lines that were not covered either before or after a Diffblue Cover analysis. These lines are marked with a red dot by default.
  • Uncovered lines that are not coverable, such as lines that are empty or contain only syntactical elements. It also refers to any lines for which a coverage status could not be determined. These lines are marked with a grey dot by default.

Filtering

Under the Filtering tab, it is possible to select the minimum star-rating of the tests generated. Only those tests ranked with at least the minimum star-rating will be added to the project.

It is also possible to select whether tests must (Required), must not (Excluded) or may (Ignored) match certain conditions:

  • Assertions presence of assertions
  • Mocking presence of mocking
  • Reflection presence of reflection
  • Verified tests run successfully
  • Failed tests tests fail to compile or run
  • Failed run tests fail to run
  • Failed compile test fails to compile

results matching ""

    No results matching ""