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?
相关问题
- Dependencies while implementing Mocking in Junit4
- Eclipse and Mylyn : how to disable grey files in t
- Installing Pydev for Eclipse throws error
- Error in Scala Compiler: java.lang.AssertionError:
- How to remove unused imports using Eclipse and not
相关文章
- selenium+eclipse 打开网页时报错
- Eclipse failing to open
- Setup and Tear Down of Complex Database State With
- Eclipse how can I indent C++ preprocessor macros
- Why is FindBugs ignoring my check for null?
- Eclipse cleanup - what are the “.index” files - ca
- Compile and build with single command line Java (L
- Eclipse plugin to find out unused methods in a cla
In this example I am passing an argument
webDriver
asfirefoxDriver
in the run configuration window:I will skip passing as somebody has already replied with that. To access you use:
(returns String)
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 Explorer. Right click and select
Run As -> Open Run Dialog
In the run dialog there is an Arguments tab where you can specify program and VM 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 Configurations
to access the Arguments tab.Probably you have figured this out, but when compiled and if using ANT or MVN, you can pass arguments to your JUNIT or TestNG from inside the POM.XML file.