• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Eclipse Newbie - JUnit Test

 
Charles Webber
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to work through some initial growing pains with Eclipse. I have a couple of classes that are in the same package. The first is just a simple JDBC class. The second is a JUnit test class that runs tests on the JDBC classes.
When I run the test class, I get a null pointer exception when attempting to instantiate the JDBC class. My take is that the JUnit class can't find the JDBC class. I checked and found that Eclipse built .class files within the project path. So, I'm not sure what is going on.
Second, I would like to know how to add a runtime property when running a class from within the Eclipse framework.
Any help is appreciated.
Thanks.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A missing class should result in a ClassDefNotFoundError, not a NullPointerException. Does the stack trace mention a line number (and if it does, would you mind posting some code around the line)?
You can add "runtime properties" by selecting "Run As..." from one of the top menus -- there should be a textarea for "JVM arguments" or something like that.
 
Charles Webber
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am posting some of of the code which is based on the output from JUnit:
public void testGetInternalID()
throws Exception
{
XRefUserExit xref = new XRefUserExit();
String intID = xref.getInternalID("9377777132519", "852");
Assert.assertEquals("9377777132519", intID);
}
JUnit indicates that the null pointer exception is from the new allocation of object xref.
Also, when I tried the "Run As.." I don't see anyplace to put any command line options or runtime parameters.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oops. It was "Run..." instead of "Run As >". When you have your unit test class open, do the following (I'm using Eclipse 3.0M6, but it should be very close in any other version of Eclipse):
1) Open the "Run" menu
2) Select the "Run..." menu option
3) Switch to the "Arguments" tab
Now, there should be two text areas: one for program arguments ("String[] args"), and one for JVM arguments ("-Djava.security.policy=foobar").
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic