Results 1 to 1 of 1
  1. #1
    mackavelirip is offline Member
    Join Date
    Feb 2011
    Posts
    9
    Rep Power
    0

    Default Junit testing, testing list<e> interface

    Hi im writing a tester that tests 13 methods from the list interface. Im having trouble with my assertEquals and assertTrue. Every single one of my assertEquals and assertTrues says there is an error. The error says "The method assertTrue(boolean) is undefined for the type List12Tester" or "The method assertEquals(Integer, Integer) is undefined for the type List12Tester" Here is an example of one of my tester methods.

    Java Code:
    public class List12Tester extends junit.framework.TestCase
    {
        //contain test that checks if the element is in the list. **boolean add(E e)**
    	public void testAddContains()
    	{
    		List12<String> l = new List12<String>();
    		l.add("cob");
    		l.add("sh");
    		assertTrue(l.contains("cob"));
    		assertFalse(l.contains("hsg"));
    	}
    }
    Thats one example but it does it for all my tester methods. The assignment is to write the tester first then List12 so it said to make a List12 class that extends java.util.LinkedList<E>.

    Another question I had was is it legal to do something like this.

    Java Code:
    //checks if index is in bounds **add(int index, E element)**
    	public void testAddIndexInBounds()
    	{
    		List12<String> l = new List12<String>();
    		
    		l.add(0,"A");
    		l.add(1,"B");
    		l.add(2,"C");
    		l.add(3,"D");
    		
    		assertTrue(l.indexOf("A") >= 0);
    		assertTrue(l.indexOf("D") <= l.size());
    		
    		
    	}
    Is it legal to do the assertTrue with >= or <=?

    Any help would be appriciated thanks.
    Last edited by mackavelirip; 10-05-2011 at 06:11 AM.

Similar Threads

  1. J2ee developer with junit testing
    By mistybws in forum Jobs Offered
    Replies: 0
    Last Post: 10-08-2010, 10:21 PM
  2. JUNIT testing assertEquals function
    By Drun in forum New To Java
    Replies: 7
    Last Post: 01-22-2010, 06:08 PM
  3. JUnit testing
    By hedonist in forum Advanced Java
    Replies: 4
    Last Post: 10-04-2009, 12:06 PM
  4. Testing tools (Profiling and JUnit)
    By ericpinet in forum Eclipse
    Replies: 1
    Last Post: 04-21-2009, 10:23 PM
  5. Testing JUnit PDE with Ant
    By keynan in forum Eclipse
    Replies: 0
    Last Post: 02-14-2008, 11:35 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •