简体   繁体   English

如何从 Java 的主类访问 src.test 包或如何从主类运行测试类?

[英]How to make acces to src.test package from main class in Java or how to run test class from main class?

I try to launch selenium test from main class and try to follow the example from next question: How do I run JUnit tests from inside my java application?我尝试从主类启动selenium测试并尝试遵循下一个问题中的示例: 如何从我的 Java 应用程序内部运行 JUnit 测试? :

JUnitCore junit = new JUnitCore();
Result result = junit.run(testClasses);

But I cannot use this resolve because I have not access to my test class from main class:但是我无法使用此解析,因为我无法从主类访问我的测试类:

在此处输入图片说明


Queation: How to correctly run test class from main class?问题:如何从主类正确运行测试类?


PS聚苯乙烯

I need to run test class from main class since is necessary build executable jar file and launched the selenium test from it.我需要从主类运行测试类,因为有必要构建可执行jar文件并从中启动selenium测试。

test文件夹中的类在构建后不包含在应用程序中,因此如果您想从主类运行PageTest ,请确保您的PageTest类不在test文件夹中。

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

相关问题 来自src / test的Jar文件中的主类 - Main class in Jar file from src/test 如何从Java中另一个类的主类访问int? - How to acces an int from the main class in another class in java? 如何使用 exec maven 插件从测试源运行主 class? - How to run a main class from test sources with exec maven plugin? want to execute a java test class which is in src/test/java from src/main/java but I am unable to import that java class in src/main/java? - want to execute a java test class which is in src/test/java from src/main/java but I am unable to import that java class in src/main/java? 无法从src \\ test文件夹“运行文件” - >找不到主要类或无法加载主类 - Cannot “Run File” from src\test folder -> main class not found or could not be loaded 无法从主包(Eclipse)访问测试包中的类 - Cannot access class in test package from main package (Eclipse) 如何从src / main / java中的src / test / resources中读取道具 - How to read props from src/test/resources in src/main/java 春季引导。 该类仅在src / java / main中运行,在src / java / test中具有异常 - Spring boot. Class run only in src/java/main, in src/java/test it has exceptions maven:如何从main中的类中导入测试类 - maven: how import from test classes in class from main 从另一个类访问主类的链接列表 - Acces linked list in main class from another class java
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM