Menu

#1374 JUnitAssertionsShouldIncludeMessage does not work

New Tickets
more-info-needed
None
PMD
3-Major
Bug
JUnitAssertionsShouldIncludeMessage
2016-01-09
2015-06-16
L.W.
No

I don't get any warnings for Assertions without message.

For example the class

import static org.hamcrest.Matchers.containsString;

import org.junit.Assert;
import org.junit.Test;

public class TestClass extends Assert {

    @Test
    public void test() {
        assertTrue(true);
        assertEquals("", "");
        assertNull(null);
        assertThat("", containsString(""));
    }
}

does not get any JUnitAssertionsShouldIncludeMessage marker

Discussion

  • Andreas Dangel

    Andreas Dangel - 2015-11-30

    Thanks for the bug report. Unfortunately I can't reproduce the problem.
    With PMD 5.3.5 I get 4 violations, one for each of the asserts.

    Which version of PMD are you using?

    Since PMD 5.3.0 (and pull request 50) assertThat is also detected correctly - earlier versions of PMD only detect 3 violations.

     
  • Andreas Dangel

    Andreas Dangel - 2015-11-30
    • status: open --> more-info-needed
    • assigned_to: Andreas Dangel
     
  • L.W.

    L.W. - 2016-01-09

    I'm using the latest pmd-eclipse from http://sourceforge.net/projects/pmd/files/pmd-eclipse/update-site-latest/
    I just rechecked that the rule is enabled and tried the above-mentioned code again. Nothing. No warning at all.

     

Log in to post a comment.