How it works...

The new concept here was the new ensure method. This is a simple example of making the data-generation side of testing as simple as possible. If we wanted to post a sales invoice, we would simply write ensureCanPostSalesInvoice. This would create the necessary data. The method can chain other ensure methods so that each ensure method remains as small as possible.

In our case, to create a vehicle, we had to just ensure that a vehicle group was created. That, in turn, created a parameter with a default vehicle group.

When we created the default, you may have noticed that we specified the instanceRelationType field. This is only required for tables that take part in inheritance and is the table ID of the table we are working with.

The code also lends itself to self-validating. Mistakes that are made when writing the various classes will usually show up as test failures. Even so, we should always test that the tests pass and fail as they should.