ArchUnit icon indicating copy to clipboard operation
ArchUnit copied to clipboard

ArchTest tests not orderable via ClassOrderer

Open wimdeblauwe opened this issue 2 years ago • 2 comments

I opened https://github.com/junit-team/junit5/issues/3129 on the JUnit project, but I have been directed to here as it seems this is something that should be handled by ArchUnit. See the linked ticket for details and a sample project.

wimdeblauwe avatar Jan 18 '23 10:01 wimdeblauwe

I just noticed https://github.com/TNG/ArchUnit/issues/852 as well which seems related (Although I don't use the @Order annotation)

wimdeblauwe avatar Jan 18 '23 10:01 wimdeblauwe

Yes, you're right on both cases. Concepts that are Jupiter-related don't work with ArchUnit out of the box and I'm also not sure every concept makes sense to be transferred. That being said, I don't think that ClassOrderer or a similar concept will help you with your use case. Because AFAIK different engines on the JUnit platform run as different units. So if we would implement ClassOrderer for the ArchUnit engine it would allow you to sort ArchUnit tests but not in relation to Jupiter tests and vice versa. However, you can configure the engine execution order, and that would pretty much be equivalent to "run ArchTests first" or "run Jupiter tests first", depending on which engine is run first. Just that you might have to specify the engines to run manually then (because if you just pick them up with the usual service loader discovery mechanism I'm not sure how the order is controlled, I would consider the order implementation detail and nothing to rely on as a constant). Unfortunately, how you configure which engines to run depends on your environment again (Maven, Gradle, etc.), so I don't think I can help you there without further information (you can see some examples for Gradle in #852 that you've already found).

codecholeric avatar Jan 25 '23 07:01 codecholeric