I would like to pass arguments to my JUnit tests from run configurations. How do I reach to JUnits main method to access to those args? Anybody knows how to do this?
thanx
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can run you unit test with -D system properties and access them from you test case with System.getProperty instead of the way you are asking. Or check the class JUnitCore main method, that is used to run a test case from command line. http://junit.sourceforge.net/javadoc/org/junit/runner/JUnitCore.html. But never done this before.
I am not sure what kind of values you intend to pass, but in general it will be good to not have your tests depend on some data passed as arguments so that your tests are self contained and easy to run.