在eclipse中传递JUnit命令行参数 [英] Passing JUnit command line parameters in eclipse

查看:606
本文介绍了在eclipse中传递JUnit命令行参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近在eclipse中使用junit,我还在学习。我知道如何在eclipse中传递命令行参数,但是如何将它们传递给Junit中的测试用例?

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?

推荐答案

不能将命令行参数传递给JUnit测试,因为没有运行main方法。您将需要使用系统属性并在测试用例中访问这些属性。

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.

在包资源管理器中选择测试类。右键单击并选择运行方式 - >打开运行对话框在运行对话框中有一个Arguments选项卡,您可以在其中指定程序和VM参数。

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.

或者,使用所需的项目作为当前项目,从主菜单中选择 Run - >运行配置以访问参数选项卡。

Alternatively, with the desired project as your current one, from the main menu select Run -> Run Configurations to access the Arguments tab.

这篇关于在eclipse中传递JUnit命令行参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆