Driving NDepend with NUnit
Asked Answered
A

1

7

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.

Allophone answered 2/2, 2009 at 19:59 Comment(0)
K
4

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

Karlene answered 3/2, 2009 at 11:45 Comment(1)
Did this realise or is it still on the todo list?Zoezoeller

© 2022 - 2024 — McMap. All rights reserved.