简体   繁体   English

我在同一个程序包中有两个Java文件-如何同时运行两个文件的测试?

[英]I have two java files in the same package- How do I run a test of both files at the same time?

One java file is the underlying code and the other is the GUI. 一个Java文件是基础代码,另一个是GUI。 The code relies on the GUI for input and the GUI needs the code for performing the tasks. 该代码依赖于GUI进行输入,而GUI需要用于执行任务的代码。

How can I run a test that lets both run? 如何运行可以同时运行的测试?

If my approach to this problem could be better, I'd also appreciate feedback. 如果我对这个问题的解决方法更好,我也希望得到反馈。 Thanks. 谢谢。

Assuming you mean you have GUI.java and Code.java and that the GUI.java contains your main 假设您的意思是您拥有GUI.java和Code.java,并且GUI.java包含您的主要

somewhere in your GUI you probably have a button or something that triggers the need to perform some calculation, that is located within code, so the call would look like 您可能会在GUI的某个位置上找到一个按钮或一些触发执行某些计算需求的按钮(位于代码内),因此调用看起来像

int result = Code.compute(param);

if Code needs to be instantiated first, it would look like this: 如果需要首先实例化代码,则它将如下所示:

Code calculator = new Code(params);
int result = calculator.compute(param);

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

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