This chapter covers
- Generation of the minimal data input for a test case.
- Comparison of the output of a function with the expected output.
- Guidance about the quality and the quantity of the test cases.
In a Data-Oriented system, our code deals mainly with data manipulation: most of our functions receive data and return data. As a consequence, it’s quite easy to write unit tests to check whether our code behaves as expected. A unit test is made of test cases that generate a data input and compare the data output of the function with the expected data output.
In this chapter, we write unit tests for queries and mutations that we wrote in previous chapters.
Theo and Joe are seated around a large wooden table in a corner of "La vie est belle", a nice little French coffee shop, located near the Golden Gate Bridge. Theo orders a café au lait with a croissant and Joe orders a tight espresso with a pain au chocolat.
Instead of the usual general discussions about programming and life when they’re out of the office, Joe leads the discussion towards a very concrete topic: Unit tests. Theo asks Joe for an explanation.
THEO: Are unit tests such a simple topic that we can tackle it here in a coffee shop?
JOE: Unit tests in general, no. But unit tests for Data-Oriented code, yes.
THEO: Why does that make a difference?