Zom*_*ies 3 java junit selenium
所以我有一个测试用例,我想把它变成一个线程.我无法扩展Thread也无法实现runnable,因为TestCase已经有一个方法void run().我得到的编译错误是Error(62,17): method run() in class com.util.SeleneseTestCase cannot override method run() in class junit.framework.TestCase with different return type, was class junit.framework.TestResult.
我想要做的是扩展Selenium测试用例以执行压力测试.我目前无法使用selenium grid/pushtotest.com/amazon云(安装问题/安装时间/资源问题).所以这对我来说更像是一个Java语言问题.
仅供参考: SeleniumTestCase是我想要进行多线程扩展以进行压力测试的.SelniumTestCase扩展了TestCase(来自junit).我正在扩展SeleniumTestCase并尝试使其实现Runnable.
创建一个实现Runnable的内部类,并从com.util.SeleneseTestCase run()方法中的新Thread调用它.像这样的东西:
class YourTestCase extends SeleneseTestCase {
public class MyRunnable implements Runnable {
public void run() {
// Do your have work here
}
}
public void testMethodToExecuteInThread() {
MyRunnable r = new MyRunnable();
Thread t = new Thread(r);
t.start();
}
}
Run Code Online (Sandbox Code Playgroud)
更新以在YourTestCase类之外使用
要从另一个类运行内部类,您需要将其设置为public,然后从外部类执行:
YourTestCase testCase = new YourTestCase();
YourTestCase.MyRunnable r = testCase.new MyRunnable();
Run Code Online (Sandbox Code Playgroud)
但是,如果您不需要在测试用例中调用它,最好使用普通类,使MyRunnable成为公共类,而不是在YourTestCase中.
希望能帮助到你.
| 归档时间: |
|
| 查看次数: |
2158 次 |
| 最近记录: |