Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring 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 ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Passing value to XML file from java class

 
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
 
author & internet detective
Posts: 40035
809
Eclipse IDE VI Editor Java
  • 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
Posts: 40035
809
Eclipse IDE VI Editor Java
  • 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.
 
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
 
The only taste of success some people get is to take a bite out of you. Or this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic