Metalama / / Conceptual documentation / Creating aspects / Testing and debugging aspects
Open sandbox

Testing aspects

There are three complementary strategies to test your aspects. For the most common scenarios, the first strategy should provide sufficient coverage.

Article Description
Testing the Aspects These tests verify that the aspect transforms code or reports errors and warnings according to your expectations. With compile-time tests, the transformed code is not executed.
Unit testing aspects at run time These tests verify the run-time behavior of the aspect. With this approach, you apply your aspect to some test target code and test the behavior of the combination of the aspect and the target code by executing the transformed code in a unit test and evaluating assertions regarding its run-time behavior. For this approach, you can use a conventional Xunit project or any other testing framework because there is nothing specific to Metalama.
Testing compile-time code These tests are classic unit tests of the compile-time logic used by the aspects without executing the aspects themselves.