Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Parametrized JUnit test case

 
Gopishankar haridas
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • 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..


 
Junilu Lacar
Bartender
Pie
Posts: 7784
62
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • 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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic