项目不会作为maven集成测试运行

时间:2014-10-03 15:49:01

标签: java eclipse maven selenium integration-testing

我创建了Maven java项目以使用Selenium并使用以下示例: http://mojo.codehaus.org/selenium-maven-plugin/examples/using-with-surefire.html

(代码略有编辑):

package Test.SeleniumTest;

import junit.framework.TestCase;

import com.thoughtworks.selenium.DefaultSelenium;

public class SeleniumExampleTest extends TestCase
{
    protected DefaultSelenium createSeleniumClient(String url) throws Exception 
    {
        return new DefaultSelenium("localhost", 4444, "*firefox", url);
    }

    public void testSomethingSimple() throws Exception 
    {

        DefaultSelenium selenium = createSeleniumClient("http://www.google.com");
        selenium.start();
        selenium.open("http://localhost:8081/SWReconciliation/");      

        selenium.stop();
    }
}

java文件将作为JUnit测试正常运行,但是当我尝试将它们作为集成测试测试运行时,我收到以下错误:

16:36:36.051 INFO - Preparing Firefox profile...
16:36:57.801 ERROR - Failed to start new browser session, shutdown browser and clear all session data
java.lang.RuntimeException: Firefox refused shutdown while preparing a profile
    at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.waitForFullProfileToBeCreated(FirefoxChromeLauncher.java:367)
    at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.populateCustomProfileDirectory(FirefoxChromeLauncher.java:120)
    at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.launch(FirefoxChromeLauncher.java:90)
    at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.launchRemoteSession(FirefoxChromeLauncher.java:412)
    at org.openqa.selenium.server.browserlaunchers.FirefoxLauncher.launchRemoteSession(FirefoxLauncher.java:114)
    at org.openqa.selenium.server.BrowserSessionFactory.createNewRemoteSession(BrowserSessionFactory.java:381)
    at org.openqa.selenium.server.BrowserSessionFactory.getNewBrowserSession(BrowserSessionFactory.java:125)
    at org.openqa.selenium.server.BrowserSessionFactory.getNewBrowserSession(BrowserSessionFactory.java:86)
    at org.openqa.selenium.server.SeleniumDriverResourceHandler.getNewBrowserSession(SeleniumDriverResourceHandler.java:810)
    at org.openqa.selenium.server.SeleniumDriverResourceHandler.doCommand(SeleniumDriverResourceHandler.java:437)
    at org.openqa.selenium.server.SeleniumDriverResourceHandler.handleCommandRequest(SeleniumDriverResourceHandler.java:407)
    at org.openqa.selenium.server.SeleniumDriverResourceHandler.handle(SeleniumDriverResourceHandler.java:151)
    at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1530)
    at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1482)
    at org.openqa.jetty.http.HttpServer.service(HttpServer.java:909)
    at org.openqa.jetty.http.HttpConnection.service(HttpConnection.java:820)
    at org.openqa.jetty.http.HttpConnection.handleNext(HttpConnection.java:986)
    at org.openqa.jetty.http.HttpConnection.handle(HttpConnection.java:837)
    at org.openqa.jetty.http.SocketListener.handleConnection(SocketListener.java:243)
    at org.openqa.jetty.util.ThreadedServer.handle(ThreadedServer.java:357)
    at org.openqa.jetty.util.ThreadPool$PoolThread.run(ThreadPool.java:534)
Caused by: org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher$FileLockRemainedException: Lock file still present! C:\Users\MC44948\AppData\Local\Temp\customProfileDir1bd92674dfc04bb792f93d02c2cd3a3c\parent.lock
    at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.waitForFileLockToGoAway(FirefoxChromeLauncher.java:318)
    at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.waitForFullProfileToBeCreated(FirefoxChromeLauncher.java:365)
    ... 20 more
16:36:57.855 INFO - Got result: Failed to start new browser session: Error while launching browser on session null
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 21.908 sec <<< FAILURE!

我使用了以下内容,但仍然会发生此错误。任何人都可以帮我解释为什么会这样吗?

0 个答案:

没有答案