![](/img/trans.png)
[英]Getting the particular (pre-formatted) text (from a website) using JSoup
[英]How do I create pre-formatted Java files in Eclipse?
我目前正在使用Selenium-RC API编写JUnit测试用例。 我正在写我的脚本,例如:
//example JUnit test case
public class myScripts extends SeleneseTestCase {
public void setUp() throws Exception {
SeleniumServer newSelServ = new SeleniumServer();
newSelServ.start();
setUp("https://mySite.com", "*firefox");
}
public void insert_Test_Name throws Exception {
//write test code here
}
}
对于每个测试,我都有一个新的JUnit文件。 现在,由于我的JUnit文件的开头基本上都相同,只是在结尾处稍有变化,所以我正在考虑创建一个预格式化的Java模板,以使用已经编写的冗余代码编写文件。 但是,我找不到有关是否可行的任何信息。 Eclipse是否允许您为某些软件包创建文件模板?
创建一个超类以添加所有通用代码。 创建模板真的很糟糕,因为事实上您要在一天结束时复制代码。
class Super extends SeleneseTestCase{
// Add all common code
}
class Test1 extends Super{
// only special test case logic
}
我也建议不要为每个测试用例创建SeleniumServer实例,这会降低测试套件的整体性能。 只要按顺序运行测试,就可以重用对象。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.