Database Reference
In-Depth Information
Unit testing in Neo4j
Unit testing is an important aspect of any development lifecycle. It not only involves the
testing of the expected outcome, but at the same time, it should also test the unexpected
conditions/scenarios and the behavior of the system.
In this fast-paced development environment where delivery models such as Agile— ht-
tp://en.wikipedia.org/wiki/Agile_software_development —or Extreme Programming— ht-
tp://en.wikipedia.org/wiki/Extreme_programming —focus on delivering the enhancements/
features in the shortest possible time, a good set of unit test suites helps developers to en-
sure that adding new code does not break the integrity of the system, no matter how far the
developers are familiar/aware of the rest of the code base. The goal of unit testing is to isol-
ate each part of the program and show that the individual parts are correct, which is also
used as a regression test suite later in the development cycle.
Even in the development models such as Test-driven Development ( TDD )— ht-
tp://en.wikipedia.org/wiki/Test-driven_development , the developer first writes an (initially
failing) automated test case that defines a desired improvement or new function, then pro-
duces the minimum amount of code to pass that test, and finally, refactors the new code to
acceptable standards.
There are several benefits of unit testing, which we will not discuss but it would be worth
mentioning a few of them:
Problem solving : Identifying and solving problems early in the development cycle
Facilitates change : Unit testing allows the programmer to refactor code at a later
date
Simplifies integration : It reduces uncertainty in the units themselves
Separation of concerns : Interfaces are separated from implementation where each
method is tested as a "unit" and the rest of the dependencies are injected by some
other means such as mocks
Neo4j data models, as we discussed in Chapter 3 , Pattern Matching in Neo4j , are evolving
and developed over the period of time, so the code that supports these evolving models is
also highly agile and is constantly changing. In these scenarios, unit testing becomes more
important and every piece of code, either added or modified, should ensure that it does not
break the other pieces of the system.
Search WWH ::




Custom Search