Integration Testing

Learn about integration testing and how we can apply it to the libraries we’ve written in this course.

We did advanced metaprogramming with our Mime and Translator libraries in the lesson Advanced Compile-Time Code Generation of Chapter 4.

Macro-driven libraries that generate large amounts of code are best tested at the integration level.

In this lesson, we’ll explore Integration testing and we will apply it to the libraries we’ve written.

Testing our generated code, not our code generation

Integration testing means we test our library behavior at the top level. When we give an input, we expect an output. We aren’t concerned with testing the individual subcomponents. Testing macro-generated code in this way is effective because it’s very difficult to isolate the AST transformation steps along the way. Instead, we use macros to generate code. Then, we test the expected behavior of the code, not the code-generation process itself.

Get hands-on with 1200+ tech skills courses.