This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
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

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Use @Parameters reading from an external file" Watch "Use @Parameters reading from an external file" New topic

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.


Anyone done anything like this before?

Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33132

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.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link:
subject: Use @Parameters reading from an external file
It's not a secret anymore!