Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Junit and Selenium - Passing objects between test cases and test suites

Ranch Hand
Posts: 430
Android VI Editor Debian
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi guys,

I am using the Junit 4 and im trying to understand how i can pass objects from the main testsuite class to individual tests. Here is an example,

What i would like to do is create a browser object and pass it on to every TestCase in the test suite.

Then on the actual test case i would like to use the browser object

Unfortunately this line

Does not work as it is complaining that i should use suite.addTest instead of suite.addTestSuite. If i do use suite.addTest() i get nullpointerexceptions but it doesnt tell me where. Im assuming that the nullpointer is probably on the browser object that was passed to it.

The reason i want to do it this way is i dont want to create a new browser object for each test case. It does work if i open the browser from within the test case but this is not what i want to do.

Any help with this will be appreciated or any suggestions to alternative approaches design wise will be appreciated.

With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic