I have recently been using junit in eclipse and I am still learning. I know how to pass command line parameters in eclipse, but how do I pass them to a test case in Junit? Also how do I access them?
Share
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 cannot pass command line arguments to the JUnit test because no main method is run. You will need to use system properties and access these in your test case.
Select your test class in the
Package Explorerview. Right click and selectRun As -> Open Run DialogIn therun dialogwindow there is anArgumentstab where you can specifyProgram argumentsandVM arguments. You should be able to enter your system property parameters here.Alternatively, with the desired project as your current one, from the main menu select
Run -> Run Configurationsto access theArgumentstab.