It seems that the syntax for running nunit has changed between nunit 2 and 3. I would like to move my existing CruiseControl.Net configuration to use NUnit 3, but I cannot work out how to modify my existing target (see below) to use nunit3. Is there documentation anywhere? Thanks for any help.
<nunit>
<environment>
<variable name="TEST_FILES_DIRECTORY" value="C:\TestPlans\TestFiles" />
</environment>
<path>C:\nunit3\Compiled\nunit3-console.exe</path>
<assemblies>
<assembly>C:\source\TestRunner\bin\Debug\Tests.dll</assembly>
</assemblies>
<includedCategories>
<includedCategory>Data</includedCategory>
</includedCategories>
<timeout>72000</timeout>
</nunit>
Related
I'm trying to create a plan on Bamboo Cloud (not Bamboo Server) for a .Net project:
Check out from Bitbucket
Nuget to get all package
MSBuild to compile the solution
NUnit to run the unit tests
1) and 3) is easy, but I can't figure out how to create tasks that run Nuget and NUnit. It seems you first have to install the executables on the build agent. I found documentation on how to do this for Linux, but not for Windows.
How do I create Nuget and NUnit tasks with Bamboo Cloud?
I did this by splitting up my Job into 4 tasks:
Source Code Checkout
As you would expect. It's the default task within a job anyway.
Download NuGet.exe
A one-liner Powershell inline script with
Invoke-WebRequest -Uri 'http://nuget.org/nuget.exe' -OutFile '.\nuget.exe'
Download all package dependencies via NuGet
This approach now seems to be the "new" recommended approach, so it's a simple CMD file that executes
nuget.exe restore
MSBuild
Using the .SLN file as parameter for the Project File option in the task and passing any needed other msbuild options in the Options field
My Bamboo server is on Linux and my remote agent is on the Windows build machine.
In your case you would follow up with the 5. task, e.g. the Nunit tests - though you may decided to put that into a separate stage, and split the tests into jobs that can run in parallel.
Edit: almost forgot: I also have a Nuget.config file
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageRestore>
<!-- Allow NuGet to download missing packages -->
<add key="enabled" value="True" />
<!-- Automatically check for missing packages during build in Visual Studio -->
<add key="automatic" value="True" />
</packageRestore>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
<add key="Syncfusion" value="http://nuget.syncfusion.com/xamarin/" />
</packageSources>
<!-- Used to specify which one of the sources are active -->
<activePackageSource>
<!-- this tells only one given source is active -->
<add key="NuGet official package source" value="https://nuget.org/api/v2/" />
<!-- this tells that all of them are active -->
<add key="All" value="(Aggregate source)" />
</activePackageSource>
</configuration>
I am using NUnit 2.6.3 and .NET framework 4.5.
I have a file, Test.NUnit, in my test project which contains:
<NUnitProject>
<Settings activeconfig="Debug"
appbase="E:\Test" />
<Config name="Debug" binpathtype="Auto">
<assembly path="bin\Debug\Test.dll" />
</Config>
<Config name="Release" binpathtype="Auto" />
</NUnitProject>
When I try to run this file I get an error message
Test load failed System.ApplicationException: Unable to find test in assembly
The problem is similar to this question. However, I can't get the answer to work.
I have a Test.dll.config file in my project which is located in E:\Test.
It contains:
<startup useLegacyV2RuntimeActivationPolicy="true">
<!--<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />>-->
<supportedRuntime version="v4.0.30319" />
</startup>
I have tried both versions of the supportedRuntime to show that I am using .NET framework 4.5.
I had a similar issue. Check your firewall blocking nunit-agent.exe trying to connect 127.0.0.1.
NUnit uses it for running tests and doesn't show the correct error if it can't connect to 127.0.0.1.
I have been searching for a few days, I have also asked a question on the cc.net forum, but still don't have the answer.
My task is to fill Web.config with specific values during the building using cc.net. Here is the example:
I'm developing an ASP.NET website, I have a Web.config with some configuration, e.g. connection string:
<add name="ContextName" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=DatabaseName;User Id = UserName;Password=UserPassword;" providerName="System.Data.SqlClient" />
After the building I want to replace some values and make the config look like this:
<add name="ContextName" connectionString="Data Source=%SERVER%;Initial Catalog=%DATABASE%;User Id = %USER%;Password=%PASSWORD%;" providerName="System.Data.SqlClient" />
I tried this solution, but it didn't help me (or maybe I didn't understand how to use it properly).
Please help me to solve the task.
Thanks!
You can try to use this Config Transformation Tool which is XDT transformation command tool based on XDT (web.config) transform engine, which allows you to run XDT transformation on any XML files. You can use ccnet's task block to run it after your msbuild
<tasks>
<exec>
</exec>
</tasks>
More on ccnet executable task see here.
For more information on XDT transformation see this link in MSDN library
You can create a target on your build file to update the web.config and call that target after the build. I use something similar in my build files, here is an example:
<target name="update-config" >
<property name="export.config" value="" unless="${property::exists('export.config')}" />
<call target="${config-settings}" /> <!-- test or stage -->
<xmlpoke file="${export.config}" xpath="/configuration/appSettings/add[#key='ContextName']/#connectionString" value="${configValue.connectionString}" failonerror="true" />
</target>
<target name="test">
<property name="configValue.connectionString" value="test connection string here" />
</target>
<target name="stage">
<property name="configValue.connectionString" value="stage connection string here" />
</target>
After executing the target that compile your code and export you can run the target update-config, in this case I'm expecting a variable export.config with the path of the exported web.config then calling another target that sets the the value of the connectionstring variable (this can be target test or stage) and finally xmlpoke the web.config with the value.
Hope this helps!
I'm getting started with WatiN to test my web interface. The problem I'm having is the following:
When I start the tests from within TestDriven.net, I have no problem. If I use the ReSharper test runner, I get this predictable AppartmentState exception.
I tried using the different options described here: http://watin.sourceforge.net/apartmentstateinfo.html#testdriven. Nothing helps.
Any suggestions?
I've use Resharper test runner in most of my watin test projects. To get it to work use the same method as for nunit:
http://watin.sourceforge.net/apartmentstateinfo.html#nunit
App.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="NUnit">
<section name="TestRunner" type="System.Configuration.NameValueSectionHandler"/>
</sectionGroup>
</configSections>
<NUnit>
<TestRunner>
<!-- Valid values are STA,MTA. Others ignored. -->
<add key="ApartmentState" value="STA" />
</TestRunner>
</NUnit>
</configuration>
With NUnit 2.5, RequiresSTA attribute should be the tool of choice.
Using Resharper 5.1 with VisualStudio 2010 Ultimate I found that I needed to change my Resharper options to disable "Shadow-copy assemblies being tested" (found in Resharper --> Options --> Tools --> Unit Testing).
Additionally, I also found that the correct naming for the config file is the one which includes the dll extension (so: assemblyname.dll.config).
I am trying to run the sample tests for NUnit, and I am getting an error. I have the supportedRuntime versions set to v1.0.3705 up to v2.0.50727. I have the requiredRuntime version set to v2.0.50727. Is this the wrong setting?
The following is the error that shows:
Metadata file 'c:\Program Files\NUnit 2.4.8\bin\nunit.framework.dll' could not be opened -- 'Version 2.0 is not a compatible version.'
I got the same problem with the CSharp examples in 2.4.8 "right out of the box" with VS2005. Here's my solution.
In nunit.exe.config, the following block is commented-out by default. Put it back in.
<startup>
<supportedRuntime version="v2.0.50727" />
<supportedRuntime version="v2.0.50215" />
<supportedRuntime version="v2.0.40607" />
<supportedRuntime version="v1.1.4322" />
<supportedRuntime version="v1.0.3705" />
<requiredRuntime version="v1.0.3705" />
</startup>
It sounds like you did that but changed the requiredRuntime from the default of v1.0.3705 to v2.0.50727
After that, I opened the CSharp project in VS2005 and converted it. The nunit.framework references all had the icon that shows they are wrong. So I deleted the nunit.framework reference from all 4 projects:
cs-failures
cs-money
cs-money-port
cs-syntax
Then I added new references to C:\Program Files\NUnit 2.4.8\bin\nunit.framework.dll to replace them.
After that the project builds fine.