hibernate - Grails 单元测试中不包含哪些动态方法?

标签 hibernate grails grails-orm

阅读有关 Grails 单元测试的文档时,我发现了以下内容:

In Grails you need to be particularly aware of the difference between unit and integration tests because in unit test Grails does not inject any of the dynamic methods present during integration tests at runtime.



^ Grails 9.1 Unit Testing Documenation

有了这个,我假设缺少的注入(inject)方法是指:
  • getBy* , .save()来自 GORM 和 Hibernate 的方法

  • 他们在这里谈论的还有其他动态注入(inject)的东西吗?

    最佳答案

    基本上所有与 GORM 相关的方法(动态查找器等)都是文档中指出的。它们在单元测试(没有模拟)中不可用,仅在集成测试中可用。

    以下是单元测试期间不可用的大多数方法。
    addTo attach count countBy createCriteria delete discard executeQuery executeUpdate exists find findAll findAllBy findAllWhere findBy findWhere get getAll getDirtyPropertyNames getPersistentValues ident isAttached isDirty list listOrderBy load lock merge read refresh removeFrom save

    关于hibernate - Grails 单元测试中不包含哪些动态方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7699000/

    相关文章:

    java - 在 Java 持久性中较旧的查询

    java - 为什么hibernate在insert和delete操作时会生成 'T_' prefix tableName?

    grails - 从 Controller 发送多个选定项到 View

    java - Grails中拦截Spring Security获取一些请求参数

    mysql - GORM 多对一映射表

    java - 服务器启动时测试数据库可用性

    java - 如何确保从同一线程调用的方法使用相同的数据库 session

    java - 运行我的应用程序时,Java 运行时环境检测到 fatal error

    java - 使用一对多关系时 Grails withCriteria 异常

    mysql - Grails Scaffold - 为 JodaTime 日期时间字段生成 MySQL 列类型