简体   繁体   中英

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. The code relies on the GUI for input and the GUI needs the code for performing the tasks.

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

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

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);

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