“Assert Your Architecture”

Archive for the ‘continuous integration’ tag

Architecture Rules eats his own Dog Food

Written by MykolaNikishov

June 20th, 2009 at 1:41 pm

Reprinted from Architecture Rules eats his own dog food with permission from Mykola Nikishov

While adding support for YAML configuration files I introduced a cyclic dependency (shame on me) in our code base. If this means nothing to you there are some reasons why introducing cycles considered as a bad practice.

How to catch problems like this one?

Your project’s build system must be ready for this. Integrate tools like Architecture Rules or any other alternative tool into your Maven, Ant or whatever build system of your choice.

Build your projects and run tests against them continuously, with Hudson, CruiseControl or TeamCity

Sounds obviously for you? For sure.

As the problem popped up as soon as it was introduced, fixing it was a trivial task. I absolutely agree with a statement that every piece of code becomes “legacy” few hours after it’s written. Distributed development teams make such things even worse. `Individuals and interactions over processes and tools’ don’t work.

How did I discovered this? First of all, this post is about eating your own dog food, right? One of the purposes of Architecture Rules is to report on cyclic dependencies among your project’s packages and classes. And my build system was ready to catch this with just running mvn test.

How this looks like? As a plain old unit test’s failure:

Results :

Tests in error:
    testArchitecture(org.architecturerules.SimpleArchitectureTest)

Tests run: 99, Failures: 0, Errors: 1, Skipped: 0

In my case more details are in the target/surefire-reports

org.architecturerules.SimpleArchitectureTest.txt:

-------------------------------------------------------------------------------
Test set: org.architecturerules.SimpleArchitectureTest
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.54 sec <<< FAILURE!
testArchitecture(org.architecturerules.SimpleArchitectureTest)  Time elapsed: 0.532 sec  <<< ERROR!
org.architecturerules.exceptions.CyclicRedundancyException: 2 cyclic dependencies found:

	-- org.architecturerules.configuration.xml depends on
	|  |
	|  |-- org.architecturerules.configuration
	|	 |-- @ org.architecturerules.configuration.xml.DigesterConfigurationFactory
	|	    \ while
	|	     |-- org.architecturerules.configuration.DefaultConfigurationFactory
	|	       \ depends on org.architecturerules.configuration.xml
	|
	-- org.architecturerules.configuration depends on
	|  |
	|  |-- org.architecturerules.configuration.xml
	|	 |-- @ org.architecturerules.configuration.DefaultConfigurationFactory
	|	    \ while
	|	     |-- org.architecturerules.configuration.xml.DigesterConfigurationFactory
	|	       \ depends on org.architecturerules.configuration
	|

	at org.architecturerules.services.CyclicRedundancyServiceImpl.buildCyclicRedundancyException(CyclicRedundancyServiceImpl.java:162)
	at org.architecturerules.services.CyclicRedundancyServiceImpl.performCyclicRedundancyCheck(CyclicRedundancyServiceImpl.java:117)
	at org.architecturerules.AbstractArchitectureRulesConfigurationTest.doTests(AbstractArchitectureRulesConfigurationTest.java:143)
	at org.architecturerules.SimpleArchitectureTest.testArchitecture(SimpleArchitectureTest.java:51)

Thanks to our Maven 2 plugin your build will fail too as soon as you introduce cycles in a dependency graph. Even if your project uses Apache Ant (sorry, it’s not my favorite tool) as a build system, you can download and use our Ant task to get the same result.

How-to setup Ant task? Sorry, it’s still not available and I have any clue. In a response to this post Mike provided this great how-to install and configure guide. Thank you, Mike!

Hudson

Written by MikeNereson

March 18th, 2009 at 7:33 pm

The Sonar team has an instance of Hudson running.  Hudson is a fantastic open source continuous integration server.

Here are some links:

Architecture Rules on Hudson
http://ci.sonar.codehaus.org/job/Architecture rules/

Build Status RSS
http://ci.sonar.codehaus.org/job/Architecture rules/rssAll

Modules
http://ci.sonar.codehaus.org/job/Architecture rules/modules

Modified Journalist Template   • Last Updated Sep-2010 © 2007 - 2010