Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Driving NDepend with NUnit

Is it possible to use NUnit to run CQL queries using NDepend? It would be nice to be able to just include the NDepend dlls in a UnitTests library and write tests like:

[Test] public void
DomainAssemblyHasNoDatabaseDependencies
...

or something similar.

This would make it very easy to integrate with Team City, and automatically fail the build if any of the static analysis tests fail.

like image 479
Robert Isaacs Avatar asked Feb 02 '09 19:02

Robert Isaacs


1 Answers

This is possible thanks to NDepend.API released with NDepend v4, and especially thanks to the namespace NDepend.CodeQuery that contains what is needed to run programatically CQLinq or CQL code queries and rules presented as a simple string.

Here is documentation to get started with NDepend.API.

We advise looking at the source code of the PowerTool named Query Code with CQLinq available in $NDependInstallPath$\NDepend.PowerTools.SourceCode\NDepend.PowerTools.sln

Notice finally, that thanks to NDepend.API, you can also write directly your code queries/rules or even static analyzer with C# or VB.NET code (hence code that can be embedded in your unit tests).

like image 100
Patrick from NDepend team Avatar answered Nov 02 '22 12:11

Patrick from NDepend team