nunit

When running NUnit and specifying a category, can all uncategorized tests be included too?

We have several hundred test classes, with a few dozen of them marked with the following attributes: [TestFixture] [Explicit] [Category("IntegrationTests")] so they will only be run in our over-night automated build. The remaining TestFixtures don't have a Category specified (and are not marked Explicit either). Here is the...

How to get NUnit to work with Visual Studio 2008

Maybe I am just forgetting something, but I cannot seem to get NUnit to work in Visual Studio 2008 Standard Edition. I am trying to use NUnit 2.5.7 in a C# class library project. I am following the structure of the samples given in the download of NUnit. Here are the steps I am doing 1) Download and install NUnit 2.5.7 2) Create C# cl...

log4Net issues with NUnit (Tried v2.5.7, 2.5.2, 2.4.8, 2.4.7)

I'm getting an error (see bottom of post) when running NUnit against a production code assembly. The production code assembly has a reference to a third party framework that uses log4net internally (Specifically, this is SimplyAccounting's SDK). The version of log4net that it uses is 1.2.9.0. Outside of this third party framework which w...

How much faster is NUnit compared to MSTest

Roy Osherove, author of The Art Of Unit Testing, has commented on a blog that of the many things NUnit supposedly does better, it being much faster is one of them. My question is how much faster though, if at all? Are we talking an order of magnitude? 10%? 50%? I'm asking this because for the moment I can't compare the two. I am tryin...

Creating a NUnit constraint meaning "{collection} does not contain {item}"

I'm struggling to make an assertion about the absence of a particular item in an enumeration. Specifically, this is what my test looks like: // Take an item from a queue of scheduled items... ItemQueue pendingQueue = schedule.PendingItems; // PendingItems is an IEnumerable<int> int item = pendingQueue.FirstItem; // ...process the item....

How to generate custom Nunit Report?

Hi All, I am posting this query with lot of hope. I have created a framework using Selenium RC with C#,Nunit and NANT. and Implement Nunit2Report for converting XML report output from Nunit to HTML format. But the HTML report are not clear as we used to get using TestNG and LoggingSelenium (Selenium Java Framework). My Query: ...

Is there a Has-Only-One constraint in NUnit?

I'm finding myself needing a lot of this sort of logic lately: Assert.That(collection.Items, Has.Member(expected_item)); Assert.That(collection.Items.Count(), Is.EqualTo(1)); I see that NUnit offers Has.Some and Has.All, but I don't see anything like Has.One. What's the best way to accomplish this without two asserts? ...

Trying to use Moles with NUnit. Getting "Moles requires tests to be an instrumented process"

I am trying to use moles with NUnit and am getting the following error "Moles requires tests to be an instrumented process". I am also using Visual NUnit within Visual Studio 2008 to get this working. Any help is welcome. ...

NUnit & Visual Studio Unit Testing Framework

Is there a way to create unit tests that can be run with the Visual Studio Unit Testing Framework as well as NUnit? I personally prefer the Visual Studio one, but the build server I am using only does NUnit, so I would like to support both if possible. EDIT: To clarify, I would like to run my own tests using Visual Studio (without add-o...

Why does my route test fail but the route works when running the application?

I've got the default route set-up: public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "Shortie", // Route name "{controller}/{id}", // URL with parameters new { controller = "Ettan", action = "Index", id = "id" } // P...

MOQ 4.0: The type initializer for 'Moq.Mock`1' threw an exception.

I'm getting the exception The type initializer for 'Moq.Mock`1' threw an exception. using Moq 4.0 I've checked around on a couple of forums and they allude to using the Moq-NoCastle version. I've tried both this and version in the Moq folder. Both with the same result. I've got a solution with 2 projects, one for my interface...

How to attach IE/FF to Visual Studio?

Suppose I have a class library cl1 and a unit test for it that is called clt1. I can use Visual Studio's Attach to Process feature to attach to NUnit runner. This lets me debug cl1, for example set break points. It's a very helpful feature for debugging. I'm in a need of this technique in Visual Studio and IE/FF. Suppose I have a web ap...

How to construct unit test

I have custom event logger, and I want to test it. [Test] public void AddLogWithExceptionAndEventLogEntryTypeTest() { const string loggerName = "mockLoggerName"; var logger = new MyLogger(loggerName); System.Diagnostics.EventLog log = new System.Diagnostics.EventLog("System"); string log...

Crash on debugging unit test via NUnit

Hi. Debugging unit tests with the NUnit 2.5.3 framework causes a crash on my machine. var app = new Application(); throws an exception System.EntryPointNotFoundException occurred Message=Unable to find an entry point named 'nonexistent_dummy' in DLL 'MSVCR80.dll'. Source=PresentationCore TypeName="" StackTrace: at non...

Code Coverage when using NUnit to test unmanaged C++

My team is currently using CppUnit for all our unmanaged C++ unit tests but I'm toying with the idea of transitioning to NUnit through either GenTestAsm (pure C#) or C++/CLI. Either way, what consequences would I face on the Code Coverage front with either of these approaches? We currently use PureCoverage to instrument our unmanaged...

Problem with Nunit 2.5 and AppDomain.CurrentDomain.SetPrincipalPolicy

The following test works fine with .Net 3.5 + NUnit 2.4.8. But the same tests does not work using .Net 4.0 + Nunit 2.5.7.10213. /// <summary> /// This test fails with unexpected exception: /// System.InvalidCastException : Unable to cast object of type /// 'System.Security.Principal.GenericPrincipal' to type /// 'System.Secur...

Testing a Monotouch app with NUnit in MonoDevelop 2.4

I'm new to both Monotouch and Monodevelop. Trying to get started with NUnit and I'm having a lot of trouble -- none of the sketchy references I can find on line seem to match what I'm seeing in the UI (MonoDevelop 2.4 on Mac OS 10.6). I've tried: Adding an "NUnit assembly test collection" project to my solution. Adding an "Empty MonoTo...

Using Console.Out.WriteLine vs Trace.WriteLine in nUnit either running in isolation or within reSharper or TeamCity

I vaguely remember reading "something" "somewhere" about using Trace.WriteLine over Console.Out.WriteLine in nUnit possibly in the context of reSharper or TeamCity but I cannot remember the details. Therefore the question is either in the context of nUnit running separately or within reSharper/TeamCity is there any benefit of using one ...

How to test content of popup IE window

Hi. I'm using Watin and Nant to create unit tests for my web site. I want to know the way how to test content of the popup IE window. That window is opening when user clicks on the link that has target="_blank", like on the example below <p> ... receives oversight and governance from the <a target="_blank" href="ihealth.html">iHealth...

Creating iOS UI components from NUnit test code

I'm trying to write a unit test for some code that programmatically creates UIButtons, but when I call this code from the test, I get a NullReferenceException. Stepping through in the debugger, it looks like UIButton.FromType() returns null. Here's the method I'm testing: public UIButton makeButton (String title, Action<IWelcomeCon...