| Author |
Eclipse Newbie - JUnit Test
|
Charles Webber
Greenhorn
Joined: Jan 15, 2004
Posts: 2
|
|
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
Joined: Jan 23, 2002
Posts: 11962
|
|
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.
|
Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
|
 |
Charles Webber
Greenhorn
Joined: Jan 15, 2004
Posts: 2
|
|
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
Joined: Jan 23, 2002
Posts: 11962
|
|
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: jrebel
|
|
subject: Eclipse Newbie - JUnit Test
|
|
|