Recent Blogs
With AWS CDK, you can practice infrastructure-as-code using your programming language of choice. Since this code is setting up cloud infrastructure, many classical unit testing approaches are not feasible. Adding Approval Testing to your project can increase confidence and safety.
Examples here will use Java, but the principles work in any language, and appropriate libraries are available.
Approval Testing
With Approval Tests, you take a snapshot of the output of your code, and verify that this output is consistent with earlier results. If the output has not changed, the test passes. The expected output is not expressed in source code but stored as data in a file. This is also shown in the example on Approvals:
Annotation Processor Testing
Creating an Annotation Processor means that you will likely also want to add tests, but this can be tricky since the runtime is the compilation process itself, meaning that you will have to invoke a compilation step during test execution. In this post I’d like to outline what you can do to ensure proper test coverage.
Annotation Processing
In Java, Annotations allow compile-time metaprogramming, meaning that it allows creating code based on other source code. I use this in Java - Lenses to create auxiliary classes for annotated records. These contain various instances and functions which need the type information of the annotated records, meaning that there is no way to this directly in the source code itself.
Ads on your Blog site
For a side project I had to add some advertisements, and while I was at it, I also added Google Ads onto my blog. Not so much as to make money (I don’t expect a lot of traffic here) but to learn how to do it in various environments. It can be a very useful skill if you are running a free website to cover hosting or if you want to provide this as a service to others.