(Selenium)中找不到静态资源从Eclipse执行的Play 2.0应用程序的JUnit测试 [英] Static resources not found in (Selenium) JUnit test for Play 2.0 application executed from Eclipse

查看:149
本文介绍了(Selenium)中找不到静态资源从Eclipse执行的Play 2.0应用程序的JUnit测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我的Play 2.0应用程序,我想从Eclipse执行(Selenium)JUnit测试。
测试用例看起来像:

For my Play 2.0 application, I want to execute a (Selenium) JUnit test from Eclipse. The test case looks like:

@Test
public void runInBrowser() {
    running(testServer(47111, fakeApplication(...)), ChromeDriver.class,
        new Callback<TestBrowser>() {
            public void invoke(TestBrowser browser) {
                browser.goTo("http://localhost:47111");
                assertThat(...);
            }
    });
}

测试服务器启动但没有静态资源(例如* .css ,* .js,* .png)在测试期间可用,即访问 http:// localhost:47111 会导致404这些资源。

The test server starts but none of the static ressources (e.g., *.css, *.js, *.png) is available during the test, that is, accessing http://localhost:47111 causes 404 for these resources.

我的路线文件包含:

GET     /assets/*file               controllers.Assets.at(path="/public", file)

静态资源位于文件夹:public\images(* .png),public\javascripts(* .js),public\stylesheets(* .css)。

The static resources are located in the folders: public\images ( *.png ), public\javascripts ( *.js ), public\stylesheets ( *.css ).

在Eclipse测试环境之外,找到所有静态资源(例如,通过播放测试在播放控制台中执行测试)。

Outside the Eclipse test environment all static resources are found (e.g., executing the tests in the play console with "play test").

任何想法?

推荐答案

最后,我找到了一个解决方案:

Finally, I found a solution:

p>

Replace

<classpathentry kind="lib" path="target/scala-2.10/classes_managed"/>

<classpathentry kind="lib" path="target/scala-2.10/classes"/>

这篇关于(Selenium)中找不到静态资源从Eclipse执行的Play 2.0应用程序的JUnit测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆