简体   繁体   English

如何在Eclipse中向现有JUnit添加测试?

[英]How do I add tests to an existing JUnit in Eclipse?

I added some methods in a class which was already under a JUnit coverage. 我在已经包含在JUnit中的类中添加了一些方法。
Now I want to extend the existing JUnit with some tests to validate the new methods. 现在,我想通过一些测试来扩展现有的JUnit,以验证新方法。

I want to know if there is a way to do this via GUI, without installing any other plugin like this answer advices. 我想知道是否有一种方法可以通过GUI执行此操作,而无需安装任何其他插件( 如此答案建议)。

Thank you in advance. 先感谢您。

Well, without the plugin, you always have the manual method. 好吧,没有插件,您总是有手动方法。

Just add the test methods to your JUnit and annotate them with @Test . 只需将测试方法添加到您的JUnit中,然后使用@Test对其进行注释即可。 This will allow JUnit to recognize the method as a test and execute it. 这将使JUnit将该方法识别为测试并执行它。 In these newly added methods, you should invoke the newly added methods of your class and check their behavior. 在这些新添加的方法中,应调用类的新添加的方法并检查其行为。

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

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