ArchUnit icon indicating copy to clipboard operation
ArchUnit copied to clipboard

Visualization

Open schauder opened this issue 7 years ago • 4 comments

I just wrote my first test with ArchUnit. I really like your DSL, much nicer than what I created with Degraph https://github.com/schauder/degraph

There is just one thing that I miss from Degraph: the ability to create visual representations of dependencies, especially in the case of failures.

Would you be interested in adding a feature that would cause a (failing) test to create a graphml file containing a diagram similar to what Degraph creates? Like this: http://blog.schauderhaft.de/degraph/documentation.html#result

Don't if I find the time, but I would be interested in creating a PR.

schauder avatar Jun 20 '17 13:06 schauder

Hi,

I know Degraph, and yes, the visualization feature would be something cool for ArchUnit as well :smiley:

The reason there is no visualization yet, is really that I simply had no time and wanted to focus on my core issue, the API to specify rules.

We've started to create an HTML visualization using d3, the POC looks pretty promising (we already have a JSON export and a graph visualizing the imported classes). I also thought about Graphml, since it provides better layout out of the box (this is something we're still struggling with, with d3). On the other hand I sometimes had problems in the past, if there were too many nodes, somehow, and the d3 version only needs a browser to create a nice and fluent interactive report. (might have been my version of yED though) An advantage of Graphml would also be, that it doesn't need any extra libraries to create the visualization, on the contrary to d3.

I would definitely be interested to add a Graphml visualization as well, if you're interested, it would be good to have a choice, if one visualization doesn't work out for the use case.

There are just some considerations that come to my mind

  • we're gonna create a new module archunit-visual for the HTML report, so it might be a good idea, to put all the visualization together (I'll probably add some service loader mechanism, to extend the core library for extra features like visualization)
  • to robustly visualize violations the ArchUnit core must probably be extended, because at the moment, there is no way to retrieve both origin and target from a violation, except for parsing the message, which would obviously be a bad idea :wink:

Anyway, if you find the time and motivation, to write a Graphml violation visualization, I'd be happy to merge it. And as soon as our HTML POC is somewhat more developed, we'll also add that as a feature branch for testing (and it will very likely go into version 0.5.0 then)...

codecholeric avatar Jun 21 '17 17:06 codecholeric

I think we agree on the pro and cons of Graphml. Back then it was (and probably still is) the easiest way to get nice visuals with a flexible layout.

I'll try to look into it.

schauder avatar Jun 22 '17 05:06 schauder

In case it helps: I tried to add an API with #16 to access information about violations of ArchRules. It's just a first shot, and the SPI is still missing, but it might be easier to program against this interface, than to parse String messages or fall back on some shady reflection :wink:

codecholeric avatar Jul 09 '17 22:07 codecholeric

As already mentioned in #127 you can also use https://gitlab.com/iternity/jplantuml to transform a PlantUML string into a selfcontained PlantUML URL. This makes it very easy and light weight to include a link to a UML visualization in your Assert messages...

aweisser avatar Dec 03 '18 10:12 aweisser