This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Testing and the fly likes Passing value to XML file from java class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Passing value to XML file from java class" Watch "Passing value to XML file from java class" New topic
Author

Passing value to XML file from java class

Kishan Radadia
Greenhorn

Joined: Jul 12, 2013
Posts: 3
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30136
    
150

Kishan,
Welcome to CodeRanch!

I'm not sure what passing a value to an XML file means. XML is static. Can you elaborate?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Kishan Radadia
Greenhorn

Joined: Jul 12, 2013
Posts: 3
By passing value I meant, can I pass value to username variable in XML file when I execute testcase from .java file.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30136
    
150

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

Joined: Sep 10, 2013
Posts: 11
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Passing value to XML file from java class
 
Similar Threads
Junit with XML inputs
Calling Junit from another java class ?
call a JUnit test from another class ?
Structure Size
xml schema with xerces parser