简体   繁体   English

如何使用java运行junit测试

[英]How to run junit test using java

Hello I'm launching a Junit test using java using this code:您好,我正在使用以下代码使用 java 启动 Junit 测试:

    JUnitCore junit2 = new JUnitCore();
    Result result2 = junit2.run(thenameoftheclass.class);

but in my junit original test there are some "VM option" (the IDEA window of cofig for junit).但是在我的 junit 原始测试中,有一些“VM 选项”(junit 的 cofig 的 IDEA 窗口)。 this VM options have the configuration to loggin in an app, are like the user and password system params.此 VM 选项具有登录应用程序的配置,类似于用户和密码系统参数。 But I am not able to insert those params when I am trying to run junit using just a java program但是当我尝试仅使用 java 程序运行 junit 时,我无法插入这些参数

Well guys I was able to find the answer.好吧,伙计们,我能够找到答案。

First of all you need to know that my project is not maven based.首先你需要知道我的项目不是基于 maven 的。

This methods are cool --->这个方法很酷--->

JUnitCore junit2 = new JUnitCore(); JUnitCore junit2 = new JUnitCore(); Result result2 = junit2.run(thenameoftheclass.class);结果 result2 = junit2.run(thenameoftheclass.class);

The problem was that when I was building the Application arguments in Intellij IDE I was filling the app password and user in the field "program arguments" but actually it was meant to be field in "VM Options" becase the java machine uses them in execution time问题是,当我在 Intellij IDE 中构建应用程序参数时,我在“程序参数”字段中填写了应用程序密码和用户,但实际上它应该是“VM 选项”中的字段,因为 Java 机器在执行中使用它们时间

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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