下面是问题所在:
Maven花了20分钟构建我的项目,18分钟是fitNesse集成测试。
这些测试是通过在本地启动Jetty服务器,然后逐个启动fitNesse测试来运行的。
我听说Selenium-grid可以同时运行多个测试。Maven有一个Selenium插件,我已经看到Selenium可以运行fitNesse测试。
但是我找不到关于连接这三个的信息?
基本上,我希望通过针对本地Jetty服务器的Selenium来运行我现有的fitNesse测试,以便在Maven中并行化它们。
这个是可能的吗?我是不是遗漏了什么?
干杯,丹尼尔
发布于 2012-03-31 03:18:59
您可以创建一个TestRunner类。
TestRunner将从文本文件中读取Fitnesse测试条目
TestRunner将创建线程,并在线程中运行Fitnesse测试,使用的是千里达: Fitnesse wiki的进程内测试运行器
http://www.fitnesse.info/trinidad
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import fit.Counts;
import fitnesse.trinidad.*;
import java.io.*;
public class InProcessRunner {
public static String testright, testwrong, testexceptions, testname,summary;
public static Counts cs;
public static int right, wrong, exceptions, totalright, totalwrong,
totalexceptions;
public static String str1, strhead , strsummary;
static UUID batchId = UUID.randomUUID();
public static void startProcessing(final List<String> tests)
throws InterruptedException {
Thread t = new Thread() {
@Override
public void run() {
try{
for (String next : tests) {
String dbhost = "jdbc:mysql://localhost/automation?user=root";
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection(dbhost);
Statement stmt = conn.createStatement();
stmt.executeQuery("select * from environment");
ResultSet rs = stmt.getResultSet();
while(rs.next()){
System.setProperty("browser", rs.getString("browserCode"));
boolean status = new File("C:\\wamp\\www\\output\\"+ batchId +"\\"+ rs.getString("browserName") +"").mkdirs();
System.out.println(status);
TestRunner tdd = new TestRunner(new FitNesseRepository(
"C:\\root\\fitnesse"), new FitTestEngine(),
"C:\\wamp\\www\\output\\"+ batchId+"\\"+rs.getString("browserName")+"");
cs = tdd.runTest(next);
right = cs.right;
wrong = cs.wrong;
exceptions = cs.exceptions;
totalright = right + totalright;
totalwrong = wrong + totalwrong;
totalexceptions = exceptions + totalexceptions;
testname = tests.toString();
testname = testname.replace("[", "");
testname = testname.replace("]", "");
summary = cs.toString();
java.util.Date dt = new java.util.Date();
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String currentTime = sdf.format(dt);
String sql = "insert into report(testName,passed,failed,exception,createdTime,batchId,browser) values ('"+ testname +"','"+ right +"','"+ wrong +"','"+ exceptions +"','"+ currentTime + "','"+ batchId +"','"+ rs.getString("browserName") +"')";
System.out.println(sql);
PreparedStatement ps = conn.prepareStatement(sql);
System.out.println(sql);
ps.execute(sql);
ps.close ();
System.out.println(" Test Passed " + totalright);
System.out.println(" Test Failed : " + totalwrong);
System.out.println(" Test Exceptions : " + totalexceptions);
}
}
}catch(Exception e){
e.printStackTrace();
}
}
};
t.start();
}
public static void main(String[] args) throws IOException {
File file = new File("C:\\root\\fitnesse\\TestList1.txt");
try {
BufferedReader bufRdr = new BufferedReader(new FileReader(file));
String csvline = null;
int c = 0;
List<String> testList = new ArrayList<String>();
while ((csvline = bufRdr.readLine()) != null) {
if (c == 1) {
startProcessing(testList);
testList = new ArrayList<String>();
c = 0;
}
testList.add(csvline);
c++;
}
startProcessing(testList);
} catch (Exception e) {
e.printStackTrace();
}
}
}发布于 2013-07-02 22:18:03
你可以用jenkins将这三者结合在一起,用jenkins代替maven。我写了一篇关于它的简短的博客http://mjvdende.com/2013/05/execute-xebium-fitnesse-tests-on-your-own-selenium-grid/
想法很简单。让Jenkins通过selenium插件控制您的selenium网格,并在jenkins中使用fitnesse插件执行您的fitnesse测试
希望这能有所帮助
https://stackoverflow.com/questions/8228723
复制相似问题