简体   繁体   English

如何以编程方式向Eclipse的junit视图添加项目

[英]How to programmatically add items to the junit view in eclipse

I found out how to programmaticaly open the junit view in eclipse 我发现了如何以编程方式在Eclipse中打开junit视图

TestRunnerViewPart jViewPart = JUnitPlugin.showTestRunnerViewPartInActivePage();

And now what I want to do is programmatically add some classes in the junit view to run them as junit tests. 现在我要做的是在junit视图中以编程方式添加一些类,以将它们作为junit测试运行。

I looked in the eclipse.jdt.junit source code but could only find some private methods that might help but nothing else. 我查看了eclipse.jdt.junit源代码,但只能找到一些可能有帮助的私有方法,但无济于事。

Any help or suggestions are appreciated. 任何帮助或建议,表示赞赏。 Thanks. 谢谢。

Maybe you want to have a look at the JUnit run configuration source code instead. 也许您想看看JUnit运行配置源代码。 That is the code which is executed when you actually run some unit test the normal way in Eclipse, and which in the end opens the Junit view for you. 这是当您在Eclipse中以正常方式实际运行某些单元测试时执行的代码,最后将为您打开Junit视图。

I like the direction the answer from Bananeweizen, but it's just a link to source code which is barely scratching the surface here. 我喜欢Bananeweizen给出的答案,但这只是源代码的链接,在这里几乎没有涉及。

Try reading ( How does Eclipse actually run Junit tests? ) and its accepted answer for a more in depth explanation of what is going on in the Eclipse JUnit world. 尝试阅读( Eclipse如何真正运行Junit测试? )及其公认的答案,以更深入地解释Eclipse JUnit世界中正在发生的事情。

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

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