• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

setUp and tearDown

 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I thought that setUp was called before each testXxxx method and tearDown was called after each testXxxx method. However, when I try to initialize my object in setUp, I get a NullPointerException.


Am I doing something wrong? Am I misunderstanding the function of setUp and tearDown?
[ December 01, 2003: Message edited by: Marilyn de Queiroz ]
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is it same to assume that you extending the TestCase class? And that the method itself isn't throwing the null pointer exception?
From a logical perspective, you are doing everything right. And the code looks fine.
[ December 01, 2003: Message edited by: Jeanne Boyarsky ]
 
Marilyn de Queiroz
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is it same to assume that you extending the TestCase class?

Yes.

And that the method itself isn't throwing the null pointer exception?

Yes.

The following code does not throw the exception.

 
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This might be stupid. But could you tell us how you are running your test.
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you totally sure you got the method signature right? It once happened to me that I accidentally wrote setup() instead of setUp()...
 
Marilyn de Queiroz
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks everyone. I must've mistyped something because I deleted those methods and retyped them and now everything works properly.
 
reply
    Bookmark Topic Watch Topic
  • New Topic