

The test shouldn’t actually communicate with the pizzeria and make the order. Some people define a unit of work as a method but this definition is quite limiting and it’s better to see a unit of work as a single logical concept.

A unit test, as the name suggest, should test a unit of work. The most straightforward solution would be to imitate all the steps in the test but you wouldn't really want to receive a pizza every time you run a test, would you? So what’s wrong with that test? The test case is supposed to validate the call is made the when I press “Make the order” button. Let’s paraphrase the pizza order example and imagine a system for ordering pizzas you want to test. Why not to use a unit test framework to list all the options and save the time on writing GUI! Does it mean you have your test suite for making pizza orders?Ī unit test framework is just a tool for writing tests but not every test written in this framework will be a (proper) unit test. How nice would it be to have a list of your favorite pizzas with an option of home delivery just by double clicking it.
Unit testing bookz code#
But the code that is actually going to be executed in that method is none of the frameworks concern. But how many of you have ever considered what make a unit test a good unit test? Unit test frameworks are just (fairly) simple runners that invoke a list of methods, one after another. Most of you probably even wrote one in your life. If you are a developer, I assume you have heard about unit tests.
