This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Testing and the fly likes Exception when using setup() in a junit testcase Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Exception when using setup() in a junit testcase" Watch "Exception when using setup() in a junit testcase" New topic
Author

Exception when using setup() in a junit testcase

Kamal Ahmed
Ranch Hand

Joined: Feb 15, 2005
Posts: 91
Hi List,

I have a rather basic question regarding junit/eclipse.

When I run the following class as a junit test in eclipse, it works ok


But when I have a setup method, like:

I get exception:



You have any ideas?

Thanks,

-Kamal.


(EDIT: edited the post to use UBB code tags)
[ January 24, 2006: Message edited by: Lasse Koskela ]
Eric Nielsen
Ranch Hand

Joined: Dec 14, 2004
Posts: 194
You have to use setUp() not setup() as the method name. With your current name, the test runner code isn't calling the test fixture initialization code and therefore you get the null pointer exception.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exception when using setup() in a junit testcase
 
Similar Threads
Junit test: cannot find test Method although that it is already defined in the test class
StrutsTestCase problem
Junit error
Can't run JUnit 4 test in Eclipse
NULL Pointer Exception