Integration Testing

We did some advanced metaprogramming with our Mime and Translator libraries in Chapter 3, Advanced Compile-Time Code Generation. Macro-driven libraries that generate large amounts of code are best tested at the integration level. Next, you’ll find out what integration testing is all about and how we can apply it to the libraries we’ve written.

Test Your Generated Code, Not Your Code Generation

Integration testing means we test our library behavior at the top level. Given an input, we expect an output. We aren’t so much 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 ...

Get Metaprogramming Elixir now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.