A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pmd/pmd/issues/647 below:

[java] JUnitTestsShouldIncludeAssertRule should support `this.exception` as well as just `exception` · Issue #647 · pmd/pmd · GitHub

RuleSet: JUnit

Description: Related to #285, the following variant on the code there will produce an error about missing assertions:

public class DigitalAssetManagerTest {
  @Rule
  public final ExpectedException exception = ExpectedException.none();
  @Test
  public void throwsIllegalArgumentExceptionIfIconIsNull() {
    this.exception.expect(IllegalArgumentException.class);
    this.exception.expectMessage("Icon is null, not a file, or doesn't exist.");
    new DigitalAssetManager(null, null);
  }
}

If either of the this.exceptions are changed to merely exception, then the reported error goes away. While the code samples in https://github.com/junit-team/junit4/wiki/Rules don't display the use of this. as a general matter, it is semantically allowed.

This is run with v5.8.1 of PMD via the command line, so it's current behavior.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4