aspose file tools*
The moose likes Testing and the fly likes Use @Parameters reading from an external file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Use @Parameters reading from an external file" Watch "Use @Parameters reading from an external file" New topic
Author

Use @Parameters reading from an external file

Theodore David Williams
Ranch Hand

Joined: Dec 21, 2009
Posts: 102
I would like to use JUnit to read in a file of parameters. I think that I can use the @Parameters annotation to do this, but I am not really sure how to get the values out of the file.

file:





Anyone done anything like this before?

Thanks
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30929
    
158

I've used @Parameters, but not from a file. However, it's just Java so you can absolutely read from a file. Just like reading from any other file. Maybe Scanner to read a line and split() to parse the columns? The only thing to watch for is that your file is in the classpath.


[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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Use @Parameters reading from an external file