【问题标题】:How to disable Play! modules tests that get in the way when running an app in test mode?如何禁用播放!在测试模式下运行应用程序时妨碍模块测试?
【发布时间】:2011-04-24 22:49:06
【问题描述】:

我刚开始玩 Play!框架,并偶然发现了这样的问题:在测试模式下运行应用程序时,作为依赖项添加的模块无法编译。 到目前为止,错误的模式重复了 2/2 次。属于失败的测试套件的引用类无法解析为类型。

我的 dependencies.yml 文件如下所示:

require:
 - play 1.2
 - secure
 - crud
 - play -> cobertura 2.1
 - play -> paginate head
 - play -> messages 1.0
 - play -> i18ntools 1.0.1
#     - play -> scaffold head

如您所见,我已经禁用了scaffold 模块,但下一行是paginate。第一次请求后出现的错误如下:

Compilation error
The file {module:paginate-head}/test/play/modules/paginate/MappedPaginatorTest.java could not be compiled. Error raised is : MockModel cannot be resolved to a type

In {module:paginate-head}/test/play/modules/paginate/MappedPaginatorTest.java (around line 16)

12:
13: public class MappedPaginatorTest {
14:     @Test
15:     public void testPaginateByKey() {
16:         Map<String, MockModel> models = new HashMap<String, MockModel>();
17:         List<String> keys = new ArrayList<String>();
18:

MockModel 类与MappedPaginatorTest 放在同一目录中。 (scaffold 模块也是如此。) 我使用 Eclipse 在两种模式下运行应用程序,但在命令行使用 play test 运行时出现相同的错误。

我不坚持修复模块以启用它们的测试。但如果这是我能忍受的唯一方式。

【问题讨论】:

    标签: playframework


    【解决方案1】:

    我找到了一个快速破解方法,可以让我禁用测试:只需从有问题的模块目录(在我的情况下为play-1.2/modules/paginate-head)重命名或删除test 子目录。

    不过,我将留下未解决的问题,以便为正确解决问题留出空间:通过修复模块问题,因为从模块中省略测试通常也会导致问题。

    【讨论】:

      【解决方案2】:

      嗯,一个答案是在 Stack Overflow 上发布这个问题,paginate 和脚手架的作者可能会偶然发现它。由于该作者恰好是我,因此模块已更新。在构建可分发模块时,似乎并非所有类文件都正确导出。

      【讨论】:

      • 这不是上述问题的答案。问题具体是如何禁用测试...
      【解决方案3】:

      这一定是游戏1.1 到2.1 的迁移问题。并非所有播放模块都迁移到播放 2.1。删除测试目录可以解决问题,但要非常小心,因为在 2.1 的测试模式下模块的行为可能会有所不同。

      我们在使用 guice 1.1.1 模块时遇到了同样的问题,即使我们删除了 guice 测试目录,我们的一些测试用例也失败了。

      我们决定迁移回 1.1 并等待几周/几个月的模块更新。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-11-26
        • 2013-05-11
        • 1970-01-01
        • 2016-12-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多