Testing Fabrics
Short of actually creating a project that covers all of the bases that one would want to cover is there a way to test fabrics present in Metalama that I have somehow missed?
10 Replies
You should be able to use the regular
Metalama.Testing.AspectTesting
approach to test fabrics too. Each test file is effectively treated as a separate project.If you'd like to test that the fabric correctly works across projects, you can use the
<Test>.Dependency.cs
which causes the test runner to create two projects - the first project that includes <Test>.cs
and references the second project which contains <Test>.Dependency.cs
.Indeed that does seem to work, thanks.
@addabis I have a whole set of fabric extensions that I'd like to test, so it may well be that your suggestion would make eminent sense in this case. Is there an example of that anywhere in the documentation?
I don't think it's used in public repos at the moment. I'm mentioning that since it's rather a small note in https://doc.metalama.net/conceptual/aspects/testing/aspect-testing under "Creating a dependent project". We use that quite extensively though.
Your right about it being a small note, however let's see if I can make sense of it.
This was the first test that I created;
I currently have seven fabric extensions that I'd like to test, and to do that properly I'd need to have a variety of different class signatures and method signatures for them to run over.
I now know that I can create separate tests for each scenario, I'm wondering if your suggestion would allow them all to be tested at once in some way.
I now know that I can create separate tests for each scenario, I'm wondering if your suggestion would allow them all to be tested at once in some way.
My suggestion was intended only for the cross assembly scenario, i.e. when it is relevant that your fabric is being inherited in another project than the one in which it was applied.
If you need to share code between test cases, you might want to have a look at the "Include other files" section.
But the target code (the transformed code you are testing aspects on) always needs to be a part of the test file and cannot be shared between tests.
Not in documentation but here:
https://github.com/postsharp/Metalama.Extensions/tree/master/src/Metalama.Extensions.Architecture
https://doc.metalama.net/conceptual/architecture/extending
GitHub
Metalama.Extensions/src/Metalama.Extensions.Architecture at master ...
Open-source extensions to Metalama.Framework. Contribute to postsharp/Metalama.Extensions development by creating an account on GitHub.
the testing is here:
https://github.com/postsharp/Metalama.Extensions/tree/master/src/tests/Metalama.Extensions.Architecture.AspectTests
GitHub
Metalama.Extensions/src/tests/Metalama.Extensions.Architecture.Aspe...
Open-source extensions to Metalama.Framework. Contribute to postsharp/Metalama.Extensions development by creating an account on GitHub.
@domsinclair Can we close this conversation?
Yes, certainly.