Question

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.

Was it helpful?

Solution

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).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top