1.

Explain TDD using Test Kitchen in Chef

Answer»

Test-Driven Development is a DevOps practise where code is developed just to make a failing test pass. It follows a red, green, refactors cycle. In the case of Infrastructure point of view, we first write a test and see it fail. Then write the code to make the test pass and then refactor if required. TDD helps to create high quality, SIMPLER code with high modularity.

In Chef, Test Kitchen helps us to perform TDD. We first write the InSpec test and run “kitchen verify” command to perform the test. If the test fails, enough code is written to make the test pass. We converge the node to the desired state USING “kitchen converge” command. Then again “kitchen verify” command is run to verify if the test has passed. Then the code is refactored if required when all TESTS have passed. In places where CI/CD is used, we can use “kitchen test “ command to invoke creation of kitchen INSTANCE, converging and verifying and at last destroyed the kitchen instance. Hence helping us to DETECT the defects very easily and in the early stages of project development.



Discussion

No Comment Found