nunit

Unit Testing File I/O

Reading through the existing unit testing related threads here on Stack Overflow, I couldn't find one with a clear answer about how to unit test file I/O operations. I have only recently started looking into unit testing, having been previously aware of the advantages but having difficulty getting used to writing tests first. I have set ...

TeamCity, invoking the TeamCity NUnit launcher from the command line

I'm trying to split up some rather lengthy unit test executions across multiple build agents with TeamCity, so I removed the unit test part of the build step (using Visual Studio 2008, sln2008 build runner) in TeamCity and trying to set up separate build steps. However, I'm unable to invoke the built-in NUnit launcher that comes with Te...

Which Unit Test framework should I start with for C# in Visual Studio 2008? (Windows Forms app)

Hi, QUESTION - If I'm starting a Windows Forms application in C# using Visual Studio 2008, which unit testing framework should I use? There seems to be one build into VS2008? Or should I look into something like NUnit? Or is NUnit what is used in VS2008 under the bonnet? What's the most popular. Would be good to have something th...

Running nUnit tests in a multithreaded fashion

Is it possible to run nunit tests in a multithreaded fashion? Is there any runner which can provide this? Before someone jump on "unit test" concept, let me explain: These are not unit tests we are using nunit for functional / integration testing as well, and some of those tests are incredibly slow, got lots of wait state. Therefore mul...

Unit test, NUnit or Visual studio ?

Hi all, I'm using Visual studio (sometimes resharper) to run my unit test. I heard about NUnit, but I don't know many things about it... Should I care about it ? Can it offer something better than visual studio ? Should I Use NUnit and why ? Thanks for your help Tim ...

Run an NUnit test without using the mouse?

When I want to run 1 test, I always have to right-click the method declaration and click "Run Test". Is there a way to do this without using the mouse? ...

Microsoft PEX with NUnit

I am thinking of using Microsoft PEX tools for my project, but I would much rather use NUnit instead of MSUnit. Apparently, PEX Extensions project was specifically created for that, but it has no releases now, and appears to be dead. Has anyone been able to do this? Thanks! ...

Testing ASP.NET MVC View Model

Hi! I'm using Nunit and Moq to test my asp.net mvc solution. Is this a good way to test that the model passed to the view is a correct object/collection? [Test] public void Start_Page_Should_Display_Posts() { var posts = new List<Post> {new Post {Id = 1}, new Post {Id = 2}}; var mock = new Mock<IRepository>(); mock.Setup(x...

Running VSTS tests without mstest.exe

From reasons I won't get into, all our unit tests are using the VSTS test framework. I now want to create an MSBuild script that runs the tests, but I don't want to use mstest.exe from various reasons (it's slower, requires Visual Studio installation everywhere, I need to maintain testrunconfig, etc.) I've seen that TestDriven.net and T...

nunit network drive, failing to load tests

We currently carry out development on a mapped drive. When I write nunit tests against a test assembly it will pick up the assembly, however does not recognise any of the tests. If I move the solultion etc to a local drive and reference it again then everything works fine. What I really woiuld like to know is why this is being caused,...

NUnit. How to automatically generate tests?

Is there any software that simplifies creation of tests? Most of the contents of tests is pretty repetitive, so I thought someone might have automated this. ...

WAP + NUnit + WebConfigurationManager Pin

Hello, I just started using NUnit to write test cases for my asp.net web application project. Some of the code written to access database values fetches the ConnectionString from a "section" defined under "configSections" of web.config file. This works fine during the normal execution of the project on a web browser. But when I access...

Ignore Test or TestFixture based on condition

We've got some integration tests in our solution. To run these tests, simulation software must be installed on the developer pc. This software is however not installed on every developer pc. If the simulation software is not installed these tests should be skipped otherwise ==> NullRefException. I'm now seeking for a way to do a "condi...

NUnit Mocking not working for Singleton Method

Bear with me, I'm new to NUnit. I come from the land of Rails, so some of this is new to me. I have a line of code that looks like this: var code = WebSiteConfiguration.Instance.getCodeByCodeNameAndType("CATALOG_Brands_MinQty", item.Catalog); I'm trying to mock it, like this (assume code is already initialized): var _websiteConfigu...

NUnit: Assert.Throws

How do I use Assert.Throws to assert type of the exception and the actual message workding. Something like this: Assert.Throws<Exception>( ()=>user.MakeUserActive()).WithMessage("Actual exception message") Method I am testing throws multiple messages of the same type, with different message and I need a way to test that correct m...

NUnit and TestCaseAttribute, cross-join of parameters possible?

I have a unit-test that tests a variety of cases, like this: public void Test1(Int32 a, Int32 b, Int32 c) Let's say I want to create test-code without a loop, so I want to use TestCase to specify parameters like this: [TestCase(1, 1, 1)] public void Test1(Int32 a, Int32 b, Int32 c) Is it possible for me with this attribute to say t...

What is the accepted practice for adding Nunit tests to an existing solution?

I have inherited a reasonable sized ASP.net solution that has no automated tests. The solution seems to include all of the source/pages in one solution with no name-spacing and no separation of tiers, so there are direct SQL calls within code behind files etc. Before making changes to this site I would like to add some unit tests, prefe...

Expecting an exception in a test but wanting to verify dispose is called anyway.

I'm unit testing a demo application, which is a POP3 client. The POP3 client implements IDisposable, so I'm trying to test a 'using' cycle. (I'm using nunit 2.5.2 and Moq 4.0) /// <summary> /// Unsuccesfull construct dispose cycle, no ILogger object given. /// Expecting ArgumentNullException. Expecting TcpClient dispose t...

Reading from web.config while running Pex explorations

I've just started using Pex to generate parameterized unit-tests for my project. However, when I let Pex run its explorations, my code crashes because it cannot read from the web.config (ConfigurationSettings.AppSettings has zero elements to be more precise). The working-directory during the explorations is: "C:\Program Files (x86)\Micro...

Does NUnit's Is.EqualTo not work reliably for classes derived from generic classes?

Today I ran into the following problem with NUnit. I have a class, that derives from a generic class. I started to do some serialization tests and tested for equality using the Is.EqualTo() function of NUnit. I started to suspect something is wrong, when a test that should have failed passed instead. When I used obj1.Equals(obj2) inste...