运行Appengine单元测试的ClassNotPersistableException(JDO,Gradle)

时间:2016-02-07 20:39:26

标签: unit-testing google-app-engine intellij-idea gradle jdo

在AppEngine中运行单元测试时,收到以下错误:

The class "biz.bookdesign.librivoxserver.UserStars" is not persistable. This means that it either hasnt been enhanced, or that the enhanced version of the file is not in the CLASSPATH (or is hidden by an unenhanced version), or the Meta-Data/annotations for the class are not found.
org.datanucleus.exceptions.ClassNotPersistableException: The class "biz.bookdesign.librivoxserver.UserStars" is not persistable. This means that it either hasnt been enhanced, or that the enhanced version of the file is not in the CLASSPATH (or is hidden by an unenhanced version), or the Meta-Data/annotations for the class are not found.
at org.datanucleus.ObjectManagerImpl.assertClassPersistable(ObjectManagerImpl.java:5464)
at org.datanucleus.ObjectManagerImpl.newObjectId(ObjectManagerImpl.java:3425)
at org.datanucleus.api.jdo.JDOPersistenceManager.newObjectIdInstance(JDOPersistenceManager.java:1618)
at org.datanucleus.api.jdo.JDOPersistenceManager.getObjectById(JDOPersistenceManager.java:1740)
...

我已使用我的模块gradle文件中的以下命令将jdoconfig.xml文件复制到我的测试类路径中:

testClasses {
    doLast{
        JDOCopy.execute()
    }
}

task JDOCopy (type: Copy)

JDOCopy {
    from 'src/main/webapp/WEB-INF/classes'
    into 'build/classes/test'
    include('**/*.xml')
}

还缺少什么?

1 个答案:

答案 0 :(得分:0)

事实证明我在测试配置中没有运行appengineEnhance任务。通过将其添加到IntelliJ中的测试配置,运行任务,增强类,并且测试正确运行。我在主菜单栏的运行/调试配置下添加了它。Run/Debug Configurations