简体   繁体   中英

Eclipse - passing VM parameter to every test in the project

I need to pass a VM parameter to every test that is run in the project. Setting this manually doesn't seem to be the most convenient solution, so is there any possibility to pass the parameter to every test automatically.

Thank you for help.

We change the JRE Configuration in Eclipse (Preferences>Java>Installed JREs). There you can set default VM Arguments which are used for anything you run with that JRE.

Now simply configure your project to use this JRE (Java Build Path) and you should be on the right way.

编辑 JRE - Eclipse

Eclipse have already a built-in JUnit for you.

You can use JUnit to run different parameters on your main program.

Run your test once, this creates a run configuration.

Run-> Run Configurations -> JUnit, select your run configuration, then you have an arguments tab to specify JVM or program arguments.

You can then duplicate this run configuration to use for other tests. I'm not aware of any way to make a default setting to be applied to all future test launches.

I think you are using "Program Argument" instead of "VM argument" now. If you use VM argument it's mean globally applied to all of your tests.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM