0
votes

I'm developing a testing tool that takes in a property file location as a command line argument and runs test suites using the contents of the property file to validate against. I'm having trouble figuring out how to pass the property file from the command line through the main java class to each of the test classes in each of the test suites. Is this even possible? Any and all help is very appreciated. I'm a total noob when it comes to JUnit.

1
What trouble are you having? Everything that is possible in your production code is also possible in test code. You can load properties using java.util.Properties.load(new java.io.FileInputStream(location)). But i suggest that you (at least at first) code those arguments in test code and not load from properties file. - Vytenis Bivainis
I don't think that this is possible. But I think there is another solution for your problem. You could explain the problem that your software will solve on the JUnit mailing list and ask for help. - Stefan Birkner

1 Answers

0
votes

I guess you can path the file name as arg of command line as -Dfilepaht="/yourfile.txt"

In BaseTest you can get that argument from map. Use System.getEnv() and get you arg by name

String path = System.getEnv().get("filepaht");
new File(path);