Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Reading test data from a file and doing i/o in a test class.  RSS feed

 
Lucky J Verma
Ranch Hand
Posts: 278
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am planning to store the test data in a file and make a program to read it because i have lot of different test data to input.
and would use StringTokenizer for that and use TAB (\t) as a delimiter or separator for columns .

My question is :
1.Would TestNg support that kind (i am new to TestNG) of development?
2.Also my test data is going to include lot of sourcecode and marked up source code with HTML tags as expected and real output.
It would include \t \t all kind of whitespaces.I am kind of worried if Java would messup with \n\t or its going tobe complex using sourcedoe and markups in this format for file.
I am not sure about using XML format for input file too.

Any suggestions would also be appreciated.

like
Language Source Expectedouput
Java Class Test{\n} <span class='k'>Class</span> Test{\n}
XML <Address><city> ......


 
Greg Charles
Sheriff
Posts: 3015
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all TestNG is just a framework that automatically runs your tests and collects statistics about them. It also provides some tools, like various assert methods, which can be useful to testing. You actually write the tests though, and you have all of Java and its APIs to work with ... which means that as far as reading input files goes, TestNG supports it because Java does.

For your second question, it's true that parsing complicated input files can be, well, .... complicated. Don't blame Java though! Newlines and tabs won't confuse Java per se, but they might confuse your test program if you're not careful in writing it. XML input can be easier because it forces a well-defined and well-understood format upon the input files, which can be verified independently of your tests. There are also Java parsing frameworks that you can use to jumpstart your parser, and reduce the need to write your own code.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!