• 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

Parametrized JUnit test case

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to create a parametrized test case using JUnit. It should read all parameters in a file say XML. Later have to popup the form for selecting the parameters at run time and then to display things after filtering. I am confused as there is no proper explanation available. Please give me a suggestion or any sample snippets to get me an idea of how to start. I dont wanna give the parameters hard coded in the JUnit test case and i want to use GUI framework like Swing to display it as a form instead of command line parameters..

Please help me in this..


 
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A few things:
1. What you're planning to do is contrary to the goal of automated testing because you are requiring user intervention via a GUI - now your tests cannot be run unattended.
2. Reading from an XML file makes your test run slower -- this is not going to be a very good unit test since it crosses a system boundary by accessing the file system. It's fine for a test to read from the file system but then it should be run with the set of integration tests, not as a unit test.
3. If you really need to allow the user to do something before you run the tests, then create a separate program that presents the GUI and reads the XML file. Once the user makes his/her selection, then you can programmatically run JUnit, specifying the user-selected parameters as if they were command line parameters. That way you can have your GUI and still write the test per normal JUnit test conventions. I still think there's something fundamentally wrong with your approach if you need to have a user intervene.

And welcome to the Ranch!
 
Hey, check out my mega multi devastator cannon. It's wicked. It makes this tiny ad look weak:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic