The usage of describe and it

It will be difficult for a computer to understand plain text, so we need to convert our grouped tests into something that a computer can understand.
Converting the syntax
Let's convert one of the features created earlier. Typically, most testing tools use blocks
describe
and
it
to describe tests.
Describe
means functionality, and
it
means a specific test. We will make the following transformation:
Feature: Our friend knows how to make a pizza. 1. Is the pizza size between 30 cm and 34 cm? 2. Is the cake brown? 3. Is the cheese melted? 4. Is the pizza warm? 5. Isn't the pizza plate dirty? 6. Did the pizza taste good for 90% customers?
describe("Our friend knows how to make a pizza", () => { it("Pizza size is between 30cm and 40 cm", () => {}); it("Cake is brown", () => {}); it("Cheese is melted", () => {}); it("Pizza is warm", () => {}); it("Pizza plate is clean", () => {}); // We changed it to a shorter form without negation. it("Pizza tastes good to 90% of customers", () => {}); });
Note that we have moved from questions to assertions. The reason is simple - less text is produced and it is more intuitive to read. Also, if it is possible to simplify an assertion to a shorter form, it is worth doing
(see Pizza plate is clean)
.
We know how to communicate with the computer and show him how to mark our tests. However, we still have some things to understand before we write implementations for our tests.
If you enjoyed it, be sure to visit us on
Linkedin
where we regularly upload content from programming.