English 中文(简体)
对更多类型的数据库进行Junnit测试
原标题:Running JUnit tests against more type of databases

I have an application that uses databases through jdbc API (in fact spring jdbc template). We want to run our unit tests against more type of databases (MS SQL, Oracle, Postgre); Thus to run a test (for example with maven) that will run a unit tests 3x times, for each specified databases.

如何奇怪地解决这一问题?

(我是想自己执行日本歌舞家,但我们也有斯波克试验)

最佳回答

根本问题是,如何在不同的非行环境中多次进行同样的测试。 你们要么可以在试验框架一级执行(例如,与一名客户共同管理,要么作为DBUnit/推广),要么在建筑工具一级实施(如果你的建筑工具有足够的灵活性)。 在这两种情况下,应当能够有一个与Junnit和Spock合作的实施。 (以这种方式,Spock提供将Uniils并入外箱)。

问题回答

你的测试是什么? 页: 1 您对数据库图示的q言? 根据答案,有两项战略:

In case it is java code you are testing, just mock up JDBC connection with mocking framework of your choice ( I would recommend jMockit ) and see that your code issues proper sql statements

In case it is database schema you can prepare SQL statements and send them to DB of your choice by most convenient means ( DBUnit could be also used for this purpose, or SoapUI, or other DB management tool )

Separating those 2 concerns would provide simpler and more robust tests for each tier.

PS: also consider to use some form of ORM - like JPA





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签