Is there any chance to get this work? I want my tests to be run by nunit2 task in NAnt. In addition I want to run NCover without running tests again.
I figured it out. You change the path of the NUnit launcher to that of TeamCity's own. Here is an example:
<mkdir dir="${build}/coverage" failonerror="false"/>
<!-- run the unit tests and generate code coverage -->
<property name="tools.dir.tmp" value="${tools.dir}"/>
<if test="${not path::is-path-rooted(tools.dir)}">
<property name="tools.dir.tmp" value="../../${tools.dir}"/>
</if>
<property name="nunitpath" value="${lib.dir}/${lib.nunit.basedir}/bin/nunit-console.exe"/>
<property name="nunitargs" value=""/>
<if test="${property::exists('teamcity.dotnet.nunitlauncher')}">
<property name="nunitpath" value="${teamcity.dotnet.nunitlauncher}"/>
<property name="nunitargs" value="v2.0 x86 NUnit-2.4.8"/>
</if>
<ncover program="${tools.dir.tmp}/${tools.ncover.basedir}/ncover.console.exe"
commandLineExe="${nunitpath}"
commandLineArgs="${nunitargs} ${proj.name.unix}.dll"
workingDirectory="${build}"
assemblyList="${proj.srcproj.name.unix}"
logFile="${build}/coverage/coverage.log"
excludeAttributes="System.CodeDom.Compiler.GeneratedCodeAttribute"
typeExclusionPatterns=".*?\{.*?\}.*?"
methodExclusionPatterns="get_.*?; set_.*?"
coverageFile="${build}/coverage/coverage.xml"
coverageHtmlDirectory="${build}/coverage/html/"
/>
As you can see, I have some of my own variables in there, but you should be able to figure out what is going on. The property you are concerned with is teamcity.dotnet.nunitlauncher. You can read more about it here at http://www.jetbrains.net/confluence/display/TCD4/TeamCity+NUnit+Test+Launcher.
Why not have NCover run NUnit? You get the exact same test results. Also, what exactly are you trying to measure when running NCover outside of the tests? There's other ways to find stale or unreferenced code.
I am having to do the same thing. I think the best we can hope for is to break open the NUnit jar file that comes with TeamCity and writing a custom task that integrates NUnit2 and NCover. I wish this wasn't so, but the NUnit2 task does not produce any visible output, so TeamCity is obviously not reading StdOut for the test results.
Related
Can someone explain the use of using all the different tasks instead of using simply <exec/>?
The PHPunit task is giving me alot of problems at the moment for example, why bother and not go for a simple <exec/> ?
Cant seem to find anything in the docs at all.
The docs are f.e. very confusing giving examples such as:
https://www.phing.info/docs/guide/stable/ch04s02.html (4.2 Writing A Simple Buildfile)
<target name="build" depends="prepare">
<echo msg="Copying files to build directory..." />
<echo msg="Copying ./about.php to ./build directory..." />
<copy file="./about.php" tofile="./build/about.php" />
<echo msg="Copying ./browsers.php to ./build directory..." />
<copy file="./browsers.php" tofile="./build/browsers.php" />
<echo msg="Copying ./contact.php to ./build directory..." />
<copy file="./contact.php" tofile="./build/contact.php" />
</target>
The copy task has a description property, you would think that this would be somehow seem logical to interpret by summary reporters or something, instead of having a echo on top of every task..
Whats the best practise?
Phing's Copy Task does not have a description property...
...other than that, if expressing an action is more concise and less error-prone when written as a [custom] task than as an unwieldy exec task I usually take that as a hint to go looking and/or write that custom task.
Sometimes going a little further and submitting a pull-request ;-)
I've inherited a java testing application written in java/eclipse/testng, I'm a .net developer. I can run the test suite just fine, but I'm having difficulty in figuring out how to rerun the tests immediately after the suite has run. Does anyone have anything to point me in the right direction?
Thanks!
rerun the tests? what do you mean by here?
Do you want to run the multiple suites one after the other?
if so
<suite name="automated suites">
<suite-files>
<suite-file path="suitea.xml" />
<suite-file path="suiteb.xml" />
...
</suite-files>
</suite>
or the same suite?
<suite name="automated suites">
<suite-files>
<suite-file path="suitea.xml" />
<suite-file path="suitea.xml" />
...
</suite-files>
</suite>
I have a standard CruiseControl.Net setup that pulls code from svn, builds, tests and produces the test results. I have a intermittent problem where the build reports success (green) but test results show 1 or 2 failures.
Running the task step manually, to run just the NUnit step, succeeds but output and test results show the test failing. I've tried ContinueOnFailure both true and false (it blows up on other options and indicates only true or false are valid values which I assume because of an older version).
Is the task supposed to error out (Errors != 0)? Or is the failure procured later perhaps in the merge test results step of ccnet.config?
Does ccnet depend on the NUnit task to fail to indicate a failed build?
Thank you.
My understanding is that ("default") it will only generate the test-results.xml, and put them in the "uber.xml" file to display the results.
http://build.sharpdevelop.net/ccnet/doc/CCNET/Using%20CruiseControl.NET%20with%20NUnit.html
And that it is overrideable with the following:
<!-- Acceptance Test Assembly -->
<exec program="nunit-console.exe" failonerror="false" resultproperty="testresult.acceptancetestassembly">
<arg value="AcceptanceTestAssembly.dll" />
<arg value="/xml=AcceptanceTestAssembly-Results.xml" />
</exec>
<!-- Check the results and fail if necessary -->
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.unittestassembly)==0}" />
<fail message="Failures reported in acceptance tests." unless="${int::parse(testresult.acceptancetestassembly)==0}" />
In our continuous integration setup, I would like to set up CruisControl.NET to automatically run all our unittests. However, I don't want to have to specify every unittest dll seperately in the configuration.
All the unittest projects are all postfixed with .Test (and all non-unittest projects are not). How can I configure CruiseControl.NET to run all the unittests from these projects (I am using v1.5.7256.1 of CruiseControl.NET)?
My current config attempt:
<nunit>
<path>$(nunit.path)</path>
<assemblies>
<assembly>$(working.dir)\**\*.Test.dll</assembly>
</assemblies>
</nunit>
I'm finding it very difficult to find documentation on this specific nunit element. Most pages I can find talk about using exec, nunit2 or another nunit element or the nunit-console commandline options.
I don't have much experience with managing the build environment and am working on an existing configuration where every assembly was specified separately in the following manner.
<nunit>
<path>$(nunit.path)</path>
<assemblies>
<assembly>$(artifact.dir)\test1.dll</assembly>
<assembly>$(artifact.dir)\test2.dll</assembly>
</assemblies>
</nunit>
Hence my failed attempt using wild cards.
EDIT:
Here is some extra xml of my configuration file to show the context a little bit:
<cruisecontrol xmlns:cb="urn:ccnet.config.builder">
<project name="MyProject">
<!-- whole bunch of other elements -->
<tasks>
<nunit>
<!-- see above -->
</nunit>
</tasks>
</project>
</cruiscontrol>
After Mightmuke's suggestion, I tried replacing the <nunit> element with his suggestion, but got the following exception: Unable to instantiate CruiseControl projects from configuration document. Configuration document is likely missing Xml nodes required for properly populating CruiseControl configuration. Unable to load array item 'property' - Cannot convert from type System.String to ThoughtWorks.CruiseControl.Core.ITask for object with value: ""
Then I tried to move the <property> and <foreach> element outside the element. Then I get the exception: Unused node detected: <property name="nunit.filelist" value="" />
I'm now trying to find out more about the <foreach> element and where I can put that, but somehow I find it hard to find any documentation about it.
EDIT2:
I found the documentation of the nunit task I'm using: http://ccnet.sourceforge.net/CCNET/NUnit%20Task.html
I specifies the element to be of type String[]. I'm not sure what that means... but it seems from the example that it just means that it must contain a list of child elements of the same name in Singular form.
PS: I realize this question is getting a bit out of hand... When the whole thing is solved, I'll try to edit it in such a format so that it might be useful to someone else later.
This is an example configuration if you were to use the nunit console.
<property name="nunit.filelist" value="" />
<foreach item="File" property="testfile" verbose="true">
<in>
<items basedir=".">
<include name="${working.dir}\**\*.Test.dll" />
</items>
</in>
<do>
<property name="nunit.filelist" value="${nunitfile.list + ' ' + testfile}" />
</do>
</foreach>
<exec program="nunit-console-x86.exe" failonerror="true" verbose="true">
<arg value="${nunit.filelist}" />
<arg value="/xml=nunit-results.xml" />
<arg value="/nologo" />
<arg value="/nodots" />
</exec>
This hasn't been tested, and there are likely better ways to skin it, but it will hopefully provide a starting point for you.
We have a .NET 1.1 solution that we are compiling using NAnt with a "solution" task.
One of the projects throws multiple warnings for missing XML comments. I know which warnings I need to suppress (from http://bytes.com/topic/net/answers/177026-suppress-missing-xml-comment-warning-during-compile), but I can't see how. The csc task has a configuration element that can be used for this, but I can't see an equivalent for solution.
Is this even possible? How can I do it?
Replace NAnt's <solution> task by NAntContrib's <msbuild> task. You can pass solution files to MSBuild as well as project files and you can pass MSBuild properties like WarningLevel then. Find an example here.
I tend to prefer running an exec task for msbuild. This will suppress all warnings:
<exec program="${msbuild_exe_path}">
<arg line='"${solution_path}"' />
<arg line="/property:WarningLevel=0" />
<!-- SNIP -->
</exec>
More info on warning level settings: http://msdn.microsoft.com/en-us/library/13b90fz7.aspx
Getting msbuild to work on .net 1.1: http://blogs.msdn.com/b/jomo_fisher/archive/2004/11/29/271748.aspx