NoSQLUnit 0.3.0釋出
Introduction
Unit testing is a method by which the smallest testable part of an application is validated. Unit tests must follow the FIRST Rules; these are Fast, Isolated, Repeatable, Self-Validated and Timely.
It is strange to think about a JEE application without persistence layer (typical Relational databases or new NoSQL databases) so should be interesting to write unit tests of persistence layer too. When we are writing unit tests of persistence layer we should focus on to not break two main concepts of FIRST rules, the fast and the isolated ones.
Our tests will be fast if they don't access network nor filesystem, and in case of persistence systems network and filesystem are the most used resources. In case of RDBMS ( SQL ), many Java in-memory databases exist like Apache Derby , H2 or HSQLDB. These databases, as their name suggests are embedded into your program and data are stored in memory, so your tests are still fast. The problem is with NoSQL systems, because of their heterogeneity. Some systems work using Document approach (like MongoDb ), other ones Column (like Hbase ), or Graph (like Neo4J ). For this reason the in-memory mode should be provided by the vendor, there is no a generic solution.
Our tests must be isolated from themselves. It is not acceptable that one test method modifies the result of another test method. In case of persistence tests this scenario occurs when previous test method insert an entry to database and next test method execution finds the change. So before execution of each test, database should be found in a known state. Note that if your test found database in a known state, test will be repeatable, if test assertion depends on previous test execution, each execution will be unique. For homogeneous systems like RDBMS , DBUnit exists to maintain database in a known state before each execution. But there is no like DBUnitframework for heterogeneous NoSQL systems.
NoSQLUnit resolves this problem by providing a JUnit extension which helps us to manage lifecycle of NoSQL systems and also take care of maintaining databases into known state.
NoSQLUnit
NoSQLUnit is a JUnit extension to make writing unit and integration tests of systems that use NoSQL backend easier and is composed by two sets of Rules and a group of annotations.
First set of Rules are those responsible of managing database lifecycle; there are two for each supported backend.
• The first one (in case it is possible) it is the in-memory mode. This mode takes care of starting and stopping database system in "in-memory" mode. This mode will be typically used during unit testing execution.
• The second one is the managed mode. This mode is in charge of startingNoSQL server but as remote process (in local machine) and stopping it. This will typically used during integration testing execution.
Unit testing is a method by which the smallest testable part of an application is validated. Unit tests must follow the FIRST Rules; these are Fast, Isolated, Repeatable, Self-Validated and Timely.
It is strange to think about a JEE application without persistence layer (typical Relational databases or new NoSQL databases) so should be interesting to write unit tests of persistence layer too. When we are writing unit tests of persistence layer we should focus on to not break two main concepts of FIRST rules, the fast and the isolated ones.
Our tests will be fast if they don't access network nor filesystem, and in case of persistence systems network and filesystem are the most used resources. In case of RDBMS ( SQL ), many Java in-memory databases exist like Apache Derby , H2 or HSQLDB. These databases, as their name suggests are embedded into your program and data are stored in memory, so your tests are still fast. The problem is with NoSQL systems, because of their heterogeneity. Some systems work using Document approach (like MongoDb ), other ones Column (like Hbase ), or Graph (like Neo4J ). For this reason the in-memory mode should be provided by the vendor, there is no a generic solution.
Our tests must be isolated from themselves. It is not acceptable that one test method modifies the result of another test method. In case of persistence tests this scenario occurs when previous test method insert an entry to database and next test method execution finds the change. So before execution of each test, database should be found in a known state. Note that if your test found database in a known state, test will be repeatable, if test assertion depends on previous test execution, each execution will be unique. For homogeneous systems like RDBMS , DBUnit exists to maintain database in a known state before each execution. But there is no like DBUnitframework for heterogeneous NoSQL systems.
NoSQLUnit resolves this problem by providing a JUnit extension which helps us to manage lifecycle of NoSQL systems and also take care of maintaining databases into known state.
NoSQLUnit
NoSQLUnit is a JUnit extension to make writing unit and integration tests of systems that use NoSQL backend easier and is composed by two sets of Rules and a group of annotations.
First set of Rules are those responsible of managing database lifecycle; there are two for each supported backend.
• The first one (in case it is possible) it is the in-memory mode. This mode takes care of starting and stopping database system in "in-memory" mode. This mode will be typically used during unit testing execution.
• The second one is the managed mode. This mode is in charge of startingNoSQL server but as remote process (in local machine) and stopping it. This will typically used during integration testing execution.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/301743/viewspace-733296/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Kurator v0.3.0版本釋出
- Fescar 釋出 0.3.0 版本, 支援 Eureka 註冊中心
- Spring Authorization Server 0.3.0 釋出,官方文件正式上線SpringServer
- 持續最佳化,欣欣向雲 | RocketMQ Operator 0.3.0 正式釋出MQ
- “文章助手”小程式釋出新版 0.3.0
- Python網頁應用開發神器fac 0.3.0全新版本釋出Python網頁
- OpenYurt v0.3.0 重磅釋出:全面提升邊緣場景下應用部署效率
- 支援邊雲協同終身學習特性,KubeEdge子專案Sedna 0.3.0版本釋出!
- Devolver釋出會多款遊戲釋出dev遊戲
- 釋出帖子
- openGauss 釋出
- 首次釋出
- K8S釋出策略,無損釋出K8S
- Istio 1.1釋出,中文文件同時釋出
- NPM包(模組)釋出、更新、撤銷釋出NPM
- netcore釋出時 swagger xml釋出丟失問題NetCoreSwaggerXML
- Logstash docker釋出Docker
- Latex 板子釋出
- Fwupd 1.9.9 釋出
- Docker 23.0.4 釋出Docker
- Ubuntu 11.10 釋出!Ubuntu
- TypeScript 4.9 釋出!TypeScript
- wxPython 4.2.0 釋出Python
- NumPy 2.0.0釋出
- Rust 1.79.0釋出Rust
- 小米釋出會
- VirtualBox 6.1.34 釋出
- Rust 1.60.0釋出Rust
- selenium 4.0 釋出
- Ruby 3.1.0 釋出
- SMProxy 1.3.0 釋出 !
- GNOME 3.34 釋出
- Ubuntu 19.10 釋出Ubuntu
- KyPHP 釋出 1.1.0PHP
- Armbian 22.02 釋出
- 測試釋出
- Rust 1.59.0釋出Rust
- QEMU 4.0 釋出
- Github Action釋出Github