Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-5724

@TypeChecked and JUnit Test using assertThat(myTestResult, notNullValue()

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.4
    • 2.0.6
    • Static Type Checker
    • None
    • Windows 7
      Eclipse Juno
      Groovy Eclipse 2.7.1

    Description

      This worked with Groovy 2.0.0, with 2.0.4 it doesn't
      (where is your test coverage?)

      package groovy.bugs.typechecker
      
      import static org.hamcrest.CoreMatchers.*
      import static org.junit.Assert.*
      import groovy.transform.TypeChecked
      
      @TypeChecked
      class AssertNotNullTypecheckerBugTest {
      
      	@org.junit.Test
      	public void sometest() throws Exception {
      		// act
      		String result = '12345'.substring(2)
      		// assert
      		assertThat(result, notNullValue())
      		assertEquals('345', result)
      	}
      }
      

      I get the following error in Eclipse

      Description	Resource	Path	Location	Type
      Groovy:[Static type checking] - Cannot call org.junit.Assert#assertThat(java.lang.Object <T extends java.lang.Object>, org.hamcrest.Matcher <T extends java.lang.Object>) with arguments [java.lang.String, org.hamcrest.Matcher <T extends java.lang.Object>] 	AssertNotNullTypecheckerBugTest.groovy	/GroovyBugs/src/groovy/bugs/typechecker	line 15	Java Problem
      

      -> The eclipse project containing this sample is attached.

      Attachments

        Activity

          People

            melix Cédric Champeau
            peti Peti Koch
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: