UNITILS 测试框架

Unitils(http://www.unitils.org/summary.html)这个Java开源类包的目的是让单元测试变得更加容易和可维护。Unitils构建在DBUnit与EasyMock项目之上并与JUnit和TestNG相结合。支持数据库测试,支持利用mock对象进行测试并提供与Spring和Hibernate相集成。Unitils设计成以一种高度可配置和松散偶合的方式来添加这些服务到单元测试中。
在进行数据库测试时能够:
 

自动维护和强制关闭单元测试数据库(支持Oracle,Hsqldb,MySql,DB2),
 简化单元测试数据库连接的设置,
 简化利用DBUnit测试数据的插入,
 简化Hibernate session管理,
 自动测试与数据库相映射的Hibernate映射对象。
在利用Mock对象进行测试时能够:
 简化EasyMock mock对象创建,
 简化mock对象注入,利用反射等式匹配EasyMock参数。
在与Spring集成时易于把spring管理的bean注入到单元测试中,支持在单元测试中使用一个用Spring配置的Hibernate SessionFactory。


功能点:

反射断言 (Reflection assert)

  • Equality assertion through reflection
  • Possibility to ignore order of collections and Java default/null values

MOCK模块(Mock module) - Makes mocking easy and maintainable

  • Simple syntax for defining and asserting invoked behavior
  • Gives you the best possible feedback so you can easily find out why a test is failing
  • Argument matchers, partial mocking, stubbing behavior, dummy objects...

注入模块(Inject module) - Easily inject test artifacts into classes and instances

  • Inject values by type and name
  • Inject into static fields, e.g. singletons, and automatically reset the old value after the test

IO模块(IO module) - Support for performing IO in tests

  • Creating temporary files and directories
  • Loading the contents of files into objects

数据库测试(Database testing) - Support for testing with databases and loading of DbUnit data sets

  • Simplify test database connection setup
  • Support for setting up a separate schema/database per developer
  • Transactional testing
  • Easy loading of data sets
  • Multi-schema data sets
  • Expected data set assertions

数据库维护自动测试 (Automatic test database maintenance) - Use DbMaintain to automatically bring your unit test databases up to date before running your tests

  • Automatic maintenance of databases with support for incremental, repeatable and post processing scripts
  • Automatically disable constraints and set sequences to a minimum value
  • Generating an XSD of the database structure for dataset xml files

Hibernate模块(Hibernate module) - Support for Hibernate database testing

  • Hibernate SessionFactory creation and session management
  • Automatically test the mapping of JPA entities / hibernate mapped objects with the database

Spring模块(Spring module) - Support for testing when your project uses Spring

  • ApplicationContext configuration and easy injection of spring managed beans into a unit test
  • Support for using a Spring-configured Hibernate SessionFactory in unit tests.

EasyMock模块(EasyMock module) - Helps you set up tests that use EasyMock as a mocking framework

  • Simplify EasyMock mock object creation
  • EasyMock argument matching using reflection equality



你可能感兴趣的:(test,UNITILS,java)