I created a jar file that launches an application to allow the user to select which test they want to run. Each test has its own class and main method. The UI application passes parameters to the main method for the class that represents the test.
我创建了一个jar文件,用于启动应用程序以允许用户选择要运行的测试。每个测试都有自己的类和主要方法。 UI应用程序将参数传递给表示测试的类的main方法。
I was able to create the executable JAR file for the UI application but nothing happens when I select the test I want to run. I think it is that JAR file can only handle one main method.
我能够为UI应用程序创建可执行的JAR文件,但是当我选择要运行的测试时没有任何反应。我认为JAR文件只能处理一个主要方法。
Below is part of the code for the application that allows the user to select which test to run.
下面是应用程序代码的一部分,允许用户选择要运行的测试。
public class UI extends JFrame {
String[] args={Environment, Browser, TestingCoverage, DBLog, "UI"};
if (chckbxEQ_CA_Home.isSelected())
{
EQ_CA_Home.main(args);
}
if (chckbxEQ_CA_Condo.isSelected())
{
EQ_CA_Condo.main(args);
}
if (chckbxEQ_CA_Renter.isSelected())
{
EQ_CA_Renter.main(args);
}
}
1 个解决方案
#1
You can do that using Junit
library.
你可以使用Junit库来做到这一点。
JUnitCore junit = new JUnitCore();
Result res = junit.run(yourTestClass);
Don't invoke the main() method to avoid any possible interruptions, just let the JUnitcore
find the appropriate test methods.
不要调用main()方法来避免任何可能的中断,只需让JUnitcore找到合适的测试方法即可。
And also don't forget to include Junit.jar
in classpath (or) include it as part of your jar file (as a fat jar).
而且不要忘记在classpath中包含Junit.jar(或)将它包含在jar文件中(作为胖罐)。
#1
You can do that using Junit
library.
你可以使用Junit库来做到这一点。
JUnitCore junit = new JUnitCore();
Result res = junit.run(yourTestClass);
Don't invoke the main() method to avoid any possible interruptions, just let the JUnitcore
find the appropriate test methods.
不要调用main()方法来避免任何可能的中断,只需让JUnitcore找到合适的测试方法即可。
And also don't forget to include Junit.jar
in classpath (or) include it as part of your jar file (as a fat jar).
而且不要忘记在classpath中包含Junit.jar(或)将它包含在jar文件中(作为胖罐)。