Example of a unit test input file?

40 views
Skip to first unread message

djangofan

unread,
Jun 23, 2009, 1:11:25 PM6/23/09
to watij
Hello, I was wondering if anyone could provide a good example of a XML
formatted input file for unit tests. I am having some trouble
coming up with a format of the XML test input parameters, not having
any experience with this.

I want to have an input file that my unit tests can load from. The
XML input file needs to have a few things such as:
1. test type/name/path so that my code can decide what test path
a particular test needs to take, whether its a single test method or a
series of multiple tests
2. the test data and what browser page and field it maps to:
such as FNAME (html: page#1, name="first") + LNAME (html: page#1,
name="last")
3. what is expected as a result of the test, there might be a
series of these, in order, depending on what I had in step#1 (above)
4. + anything else i didnt think of

I would rather not come up with my own thing and then find out later
that I didn't do it the "standard way".

John Overbaugh

unread,
Jun 23, 2009, 1:19:58 PM6/23/09
to wa...@googlegroups.com
Not sure there is a standard way, and I can't imagine the first and lowest-hanging fruit for unit testing would include data-driven testing. What framework are you building/using which requires an XML-based test data input file?

John O.
http://thoughtsonqa.blogspot.com
--
John Overbaugh
blog: http://thoughtsonqa.blogspot.com

Darrell Grainger

unread,
Jun 23, 2009, 1:42:54 PM6/23/09
to wa...@googlegroups.com
Not sure how this relates to Watij. Watij is Java code based on JUnit. 

I know you can use Properties class to read and write data from properties or XML files. This is a pure Java feature. Essentially, the Java Properties class has storeToXML and loadFromXML methods for writing and reading Java properties to and from XML files. If you create a Properties object and then save it to file using storeToXML you will see the format for the Java Properties XML files.

The only other thing which pops to mind when talking about testing and XML formats for test cases would be JMeter. JMeter test cases are stored in an XML format. This however is totally unrelated to Watij.


2009/6/23 djangofan <djan...@gmail.com>

Issam Qadan

unread,
Jun 23, 2009, 1:52:27 PM6/23/09
to wa...@googlegroups.com
You do something like that:-

<?xml version="1.0"?>
<mainTestConfig>
<TestConfig>
<deploy_source_root>C:\deploysource</deploy_source_root>
<deploy_target_root>C:\deployTarget</deploy_target_root>
<deploy_host>localhost</deploy_host>
<deploy_port>123</deploy_port>
<deploy_root>abc</deploy_root>
<jdbc_properties_user>usrName</jdbc_properties_user>
<jdbc_properties_password>usrPW</jdbc_properties_password>
<jdbc_properties_url>connStr</jdbc_properties_url>
<log_root>c:\test\logs\testapp</log_root>
<result_root>c:\test\results\testapp</result_root>
<debug_flag>N</debug_flag>
<log_level>V</log_level>
</TestConfig>
</mainTestConfig>

Issam Qadan

unread,
Jun 23, 2009, 1:59:43 PM6/23/09
to wa...@googlegroups.com
Here is an example of data driven similar to what u r asking about:
http://msdn.microsoft.com/en-us/library/ms182527.aspx

djangofan

unread,
Jun 26, 2009, 2:25:20 PM6/26/09
to watij
Thanks Darrell and Issam.

1. Thanks for the suggestion of using the Java Properties object and
its XML feature. I think that is what I would like to use.

2. Also, thanks Issam for the example.

Finally, I can't imagine not driving test cases from a configuration
file that holds a list of tests. Are you guys suggesting that when
people use WATIJ that they generally dont configure sets of test
cases in a config file? That seems unbelievable to me. Maybe you
guys aren't understanding my question in some fashion? Are you
saying you hard code the tests and expected results into your test
methods? That seems terribly inefficient but on the other hand I
haven't even truly started developing yet and so maybe I am missing
something?
Reply all
Reply to author
Forward
0 new messages