java 推荐一个 JPA 单元测试框架

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/452630/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 12:26:51  来源:igfitidea点击:

Suggest a JPA Unit test framework

javaunit-testingjpa

提问by Mohan Narayanaswamy

How to unit test JPA code? is there any way to generate Unit Test case itself?

如何对 JPA 代码进行单元测试?有没有办法自己生成单元测试用例?

Note: I am lazy and new to Unit Test code.

注意:我对单元测试代码很懒惰并且不熟悉。

采纳答案by Adeel Ansari

Check this out, Unitils. Here is a related discussion, with some example codes.

看看这个,Unitils。这是一个相关的讨论,有一些示例代码。

Here is the example, showing DBUnit, Spring and OpenJPAtogether. You might not using all, but this can take you somewhere if you want to go with DBUnit, I believe.

这是示例,将DBUnit、Spring 和 OpenJPA一起显示。您可能不会全部使用,但我相信,如果您想使用DBUnit,这可以带您到某个地方。

回答by Kimble

I'm in the middle of trying out OpenEJB (http://openejb.apache.org/) for my ongoing project. It's an embeddable container with support for EJB 3.0 (and partially 3.1). My first impression of it is fairly good.

我正在为我正在进行的项目试用 OpenEJB ( http://openejb.apache.org/)。它是一个可嵌入的容器,支持 EJB 3.0(和部分 3.1)。我对它的第一印象相当不错。

回答by Tomasz Krzy?ak

recently I faced a problem of testing:

最近我遇到了一个测试问题:

  1. business logic operating on JPA Entities
  2. complex JPQL queries mixed with business logic.
  1. 在 JPA 实体上运行的业务逻辑
  2. 混合了业务逻辑的复杂 JPQL 查询。

I used JPA-Unitand it solved all my problems.

我使用了JPA-Unit,它解决了我所有的问题。