• Post Reply Bookmark Topic Watch Topic
  • New Topic

JUnit Testing?  RSS feed

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm attempting to run some tests on a DoublyLinkedList class I have created. In order to do so, I'm creating an ArrayList to compare to the DoublyLinkedList. Here's my current method:



My DoublyLinkedList class extends AbstractList, but I am receiving the error: "cannot find symbol
symbol : class ArrayList
location: class DoublyLinkedListTest"

I'm confused as to why I'm having trouble using an ArrayList here?

Thanks!
 
Sheriff
Posts: 11496
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you import java.util.ArrayList? Also, what does any of this have to do with your subject, "JUnit Testing?"?
 
Sheriff
Posts: 4935
334
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If this method is meant to be a test method, don't use such method name as DoublyLinkedListTest, it doesn't say anything useful about your test case.
Test method name should reveal its full intention, that could be even 20 words if needed.

Are you using JUnit testing framework? I don't see any annotation above the method.

Which Java version you use?
When you initialize you don't need to supply parameter type on the right hand side (bolded) ArrayList<String> test2 = new ArrayList<String>();.
Since Java 7 it is called diamond operator, so you can write just ArrayList<String> test2 = new ArrayList<>();

Please fix code indentation on line 4. That closing curly brace should be aligned with keyword public. Also, when you indenting your code, use 4 spaces for shifting.
Currently you have 2 spaces only, that could become tricky to read when the class gets bigger.

[edit] I just noticed it is not a method, but rather a class. Same as Junilu, please clarify what are you trying here. Thank you.
 
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Carly Griffin wrote:My DoublyLinkedList class extends AbstractList...

Hmmm. Doesn't sound right to me. Unless you have some sort of fast mechanism for random retrieval, it should probably extend AbstractSequentialList (←click), which is itself an extension of AbstractList; otherwise you're likely to have to write a lot more of the class yourself.

Java's own LinkedList (which is also double-linked) extends ASL.

Winston
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!