NDepend Task for Nant - nant

I am in process of creating a Nant BuildFile which will use MSBuild, Nunit, Ncover and Ndepend for compilation, unit test, code coverage and Code quality check. I am not able to find any task for Ndepend in Nant. It would be helpful if someone can share the task syntax.
Regards
Anuj

The command line options are available at:
http://www.ndepend.com/docs/ndepend-console
These can be executed through Nant scripts as mentioned in below link:
http://ncodex.googlecode.com/svn/tags/0.3.0.50/Build/Packages/nDepend/bin/NAnt/ReadMe.txt
There is just one mandatory argument. All other arguments can be passed in any order.
It is a popular tool and I am surprised not many posts are available. I missed the command line argument page in NDepend site because it is by the heading NDepend Console. Hope it helps others going forward!!

Related

OpenCover not finding solution modules

I'm trying to use OpenCover to produce some code coverage reports for my solution. I've got it running with assistance from this blog post http://www.allenconway.net/2015/06/using-opencover-and-reportgenerator-to.html, but it's currently not identifying and loading the modules which I want to report on.
Here is what I'm executing:
"%~dp0..\packages\OpenCover.4.7.922\tools\OpenCover.Console.exe" ^
-register:user ^
-target:"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\mstest.exe" ^
-targetargs:"/testcontainer:\"%~dp0..\My.Project_Tests\bin\Debug\My.Project_Tests.dll\" /resultsfile:\"%~dp0My.Project.trx\"" ^
-filter:"+[My.Project*]* -[My.Project_Tests]*" ^
-mergebyhash ^
-skipautoprops ^
-output:"%~dp0\GeneratedReports\WebsiteReport.xml"
The output I get:
No tests to execute.
Committing...
No results, this could be for a number of reasons. The most common reasons are:
1) missing PDBs for the assemblies that match the filter please review the
output file and refer to the Usage guide (Usage.rtf) about filters.
2) the profiler may not be registered correctly, please refer to the Usage
guide and the -register switch.
I've tried changing the filter to include everything:
-filter:"+[*]*"
This finds and reports on code coverage within the test project, but doesn't manage to identify or report on coverage in any of the referenced projects which I actually want to test (My.Project).
The projects are all being built and .pdb files are present in the bin folder of the test project.
I would like code coverage reports from all projects referenced by my test project. Does anyone have any idea what's going wrong?
Turns out that I'm an idiot and was running MSTest when I should have been running NUnit console since our tests are all using NUnit.
Posting this just in case it helps someone else out.

How to pass arguments to command line build task in VSTS?

Can anyone briefly explain to me how to add build and pass arguments to command line build task in VSTS (TFS Online) or suggest me some good links?
The build task is actually a wrapper around MSBuild. So whatever you can achieve using MSBuild, can be passed to the build task.
MSBuild Documentation

Running NCover from code

Is it possible to run NCover automatically from code instead of running NCover manually or via command line?
Here is the scenario, I have written a few tests, I execute all the tests and after the tests are completed, NCover should run automatically for that particular test project and store the coverage report as an XML in a location.
Is this possible to do? Kindly help.
Running NCover from the command line was the only option with NC3. When we updated NC4 the default works like this --> you create a project, the NCover service watches for a process to start that meets the match rules defined in the project, and then collects coverage on it.
This doc may be of some help: http://www.ncover.com/support/docs/desktop/user-guide/coverage_scenarios/how_do_i_collect_data_from_nunit
If you have more questions, please reach out to us at support#ncover.com.

NCover support with Moles

In our project we use NCover to measure our code coverage. If we measure tests which uses Moles the code coverage for those classes are not measured (0%).
This has something to do with both Moles and NCover using the .NET profiler.
After some searching on the internet I tried the following in command prompt without any result:
set COR_PROFILER={3FB1CC1E-1C17-4A37-9C18-BF3DB8F10E46} moles.runner.exe /pi:Dispatch /r:"C:\Program Files\NCover\NCover.Console.exe" "C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\MSTest.exe" /args:/testcontainer:..\Bin\TestLib.dll"
The number behind the COR_PROFILER is the NCover.Lib.x86.dll GUID which I previously registered with regsvr. Also adding COR_ENABLE_PROFILING=1 as env.var doesn't help.
Is there anyone who got this profiler chaining working or has experience with .NET profiler chaining?
I dug around and found a way to use NCover in at least one simple example using Moles context. Check out this thread: http://www.ncover.com/forum/show_topic?id=1191
Ruud,
Unfortunately, Moles and NCover are incompatible at this time. The problem lies in the fact that NCover sets up some environment vars, which Moles subsequently resets for its own use during the profiling session. It's definitely something that needs to be tackled. You might try asking the folks at Microsoft to consider a workaround for this issue.
Have you tried the CLRMONITOR_EXTERNAL_PROFILERS environment variable?
set CLRMONITOR_EXTERNAL_PROFILERS={3FB1CC1E-1C17-4A37-9C18-BF3DB8F10E46}
And then run ncover to call mstest as normal you would otherwis
I used this technique successfully with OpenCover see No Coverage for Moles Tests on x64 Windows Server 2003

How do I automate unit tests for a console application in TeamCity?

I've written a console application that has a number of unit tests and I'm wanting to include it in my nant build script so that it will be run on our TeamCity CIS.
Unfortunately I'm not quite sure how to do that. The nant script has examples of current projects that have been added...they they all have to supply the assemblies that need to be tested. ie MyProject.dll But my console app doesn't have anything like that since it compiles into MyProject.exe
There must be a way to automate these tests since I'm able to run the unit tests from within Visual Studio without issue.
Does anyone know if and how this is possible?
The answer to this question is that you add the name of the executable in the same place you add the list of DLL assemblies. The set of unit tests is compiled into the executable instead of into a separate dll file.
Gishu is the one who should take credit for this answer...since he answered me via a comment...however, I'm wanting to mark this question as answered so I'm writing up the answer so others can benefit from the solution.
Gishu, if you ever come back to this question, please feel free to write up your comment as an answer and I'll change the accepted answer to yours.
What Test framework do you use for those tests? You've mentioned Visual Studio, I may guess it is mstest. TeamCity added support for MSTest starting from 4.0 for sln2008 build runner.
Could you please have a look to a full list of supported .NET unit test frameworks at
http://www.jetbrains.net/confluence/display/TCD4/.NET+Testing+Frameworks+Support
Any way, have a look to custom unit tests integration manual pages at
http://www.jetbrains.net/confluence/display/TCD4/Build+Script+Interaction+with+TeamCity
I've just noticed xUnit tag. xUnit supports TeamCity. Please refer to
http://www.codeplex.com/xunit/WorkItem/View.aspx?WorkItemId=4278
for more details.