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

Passing value to XML file from java class

 
Kishan Radadia
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am performing unit testing using JUnit where I am testing my code using test cases defined in xml file.

I am creating a user using the test case defined in xml file. But the catch is I want to create mutiple users with different names.

Is it possible to possible to pass value(username) to xml file from the java class where testcases are executed?

Thanks
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34973
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kishan,
Welcome to CodeRanch!

I'm not sure what passing a value to an XML file means. XML is static. Can you elaborate?
 
Kishan Radadia
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By passing value I meant, can I pass value to username variable in XML file when I execute testcase from .java file.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34973
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using XSLT or something on top of XML? Or trying to pass the filename. Because again, XML is just data. It isn't an executable program that you can pass a value to.
 
Doug Slavens
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you considered using TestNG? One of the features of TestNG is that is allows parameters to be passed from the test suite xml file directly to the test method. Also, TestNG has an @DataProvider annotation that can be used to create an object array in which the test is run once for every element in the array.

TestNG
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic