Showing posts with label junit.framework.TestCase. Show all posts
Showing posts with label junit.framework.TestCase. Show all posts

Friday, 19 June 2015

Junit Error: assertEquals() method undefined for the type

There are 2 ways to fix this error depending on the junit version you are using.

1. If you are using Junit 4.X,  you need to have the following import statement 
    import static org.unit.Assert.* 

   This Assert class contains the set of assertion methods useful for writing tests. 
   For ex it has assertArrayEquals(), assertEquals(), assertFalse(), assertTrue() etc. 

   All these static methods can be referenced with out prefix in the code.

   Please refer to the below link for more info on static class.


2. If you are using Junit 3.X , you need to import junit.framework.TestCase and your
    test class should extend the TestCase. By extending the junit.framework.TestCase,

    It inherits junit.framework.Assert default and your test class will have the access
    to the Assertion methods.