nunit

NUnit Assert.AreEqual DateTime Tolerances

Hey everyone, I'm wondering if anybody's found a good solution to this: In our unit tests; we commonly use Assert.AreEqual() to validate our results. All is well and good; until we start trying to use this on DateTime properties. Although the times are very similar, sometimes they are off by milliseconds, which causes the tests to fa...

Nunit-agent debug workaround

I attached to nunit-agent.exe about 49 times today, and my fingers are getting tired. I was wondering if there is an automated way to get the nunit-agent.exe attach to the debugger within Visual Studio 2010? ...

How to access the NUnit test name programmatically?

Is there some global state somewhere that I can access the currently-running test name? I have tests which output files into a directory and read them back in. I'd like each test to create a directory to play in and then clean up after itself, and I don't want to push that name in (I'd have to make it unique, and then make sure each tes...

Trace in NUnit works only while debugging from Visual Studio

I want to display trace info into Text Output tab in NUnit GUI (ver. 2.5.7, target runtime 4.0): Trace.Listeners.Add(new ConsoleTraceListener()); Trace.WriteLine("Hello NUnit"); This works fine when I launch NUnit GUI from Visual Studio (2010) via Debug -> Start external application. But when from .nunit project file and console runn...

Nunit parameterised TestFixtures with parameters set at runtime?

I'm interested in being able to instantiate multiple testfixtures with constructor arguments passed to it at runtime by a static method or property returning an IEnumerable. In Nunit 2.5 they introduced parameterised tests and test fixtures. These allow you to write a single test and run it with several inputs provided using the TestCas...

NUnit with Windows Phone 7

I'd like to unit test my Windows Phone 7 libraries with NUnit. Is there a version of NUnit compatible with Windows Phone 7? ...

Pattern for creating a graph of Test objects?

I have to write Unit Tests for a method which requires a complex object Graph. Currently I am writing a Create method for each Test as shown below. 1. private static Entity Create_ObjectGraph_For_Test1() 2. private static Entity Create_ObjectGraph_For_Test2() ...... And So on The create method has about 10 Steps and they might vary by...

How can I create a generic BaseTest with NUnit that I can inherit from and have tests from the base run?

So basically i have a domain object and a generic repository that can do CRUD operations with that object. public interface IBaseRepository<T> where T : BaseEntity { void Add(T entity); void Remove(T entity); T ById(int id); IEnumerable<T> All(); } So I have several implementations of this interface, one for each domai...

Running all NUnit tests in all assemblys from Cygwin command line

Hey all, I'm trying to create a short bash script someone could run in cygwin to execute all nunit tests in a .NET project using nunit-console. Currently i have the system version of nunit aliased to "nunit" so if i run "nunit" it will execute nunit-console. My first step was to try and find all the test assemblies recursively. This ...

NUnit global initialization - bad idea?

We need some global one time setup code in our test suite. We can do it more than once but it takes quite some time. It's required by all fixtures so [TestFixtureSetUp] does not work. It has to run before all [TestFixtureSetUp] code. Put it in Main() since we keep test assemblies as executables. However Main doesn't get executed under...

Can WatiN open a html/js doc that is compiled into an Nunit test assembly?

MVC 2 app with a Web project (including external JS files used by Views) and a Tests project (including a Nunit test to launch QUnit tests with WatiN). Everything runs fine if I include the QUnit test html and JS in the Web project and use Cassini to launch it. However, I want to avoid having any QUnit test code in the Web project, so ...

NUnit - assembly that reads and writes file

I am unit testing an assembly that uses File.WriteAllLines() and File.ReadAllText() to read and write persistent data. When I run the unit test with the NUnit Gui the test fails with an unauthorizedAccessException. The path that the file is attempting to read and write is being affected of course by the location of program execution. ...

NUnit in Finalbuilder: How can I provide a path to nunit-console without the finalbuilder option

My shop has a precedent of checking in 3rd party tools to source control and using relative paths in projects/builds to find everything. Also, as NUnit releases new versions there have been several versions of NUnit admitted to this 3rd party libraries section in source control, so that changing older tests wasn't necessary to start usin...

ASP.NET + NUnit : Good unit testing strategy for HttpModule using .NET 4

I have the following HttpModule that I wanted to unit test. Problem is I am not allowed to change the access modifiers/static as they need to be as it is. I was wondering what would be the best method to test the following module. I am still pretty new in testing stuff and mainly looking for tips on testing strategy and in general testin...

Any .net Code Coverage Plugin for Visual Studio 2010?

Can anyone please suggest me a good .net code coverage plugin for Visual Studio 2010 except dotCover? [dotCover 1.0 RC is buggy, it hangs VS 2010] The VS2010's own coverage tool does not support nUnit tests. I want a plugin which supports nUnit tests also. ...

Unit Test Best Practices For Visual Studio Solutions

Hey all, I've been tasked to re-architect our build process here at work and I would like to start including unit testing (nUnit) to our projects. Through my research I've got a good grasp on the technology I'll be using, but I wanted to get some advice on best practices on setting up my solution for testing and to make sure my proposed...

Teamcity not DLL's for some NUnit Test projects

I get this error when running my Moq tests through Teamcity 5 Test(s) failed. System.IO.FileNotFoundException : Could not load file or assembly 'Moq, Version=3.1.416.3, Culture=neutral, PublicKeyToken=69f491c39445e920' or one of its dependencies. The system cannot find the file specified. at MyCode.Tests.SomeHandlerT...

Why my SqlConnection hang forever when working with NHibernte + Spring.Net

Hi everyone: I wrote an test case extending the Spring.Net's AbstractTransactionalDbProviderSpringContextTests class and trying to do something like this. Step.1 MyHibernateDao.Find(id) Step.2 Use SqlConnection API to insert some record into database. Either step.1 or step.2 can run successfully, but if I put them together, step.2 wi...

Is it possible to run tests using the nUnit framework in a hosted website?

First, let me pledge my allegiance to unit testing over integration testing, I like unit testing very much. But I have other tests that are essentially deployment tests (you can't test how the production deployment went using a unit test on a build server) and I'd like to use the nUnit framework to run these. But, the production server...

nunit problem loading exe

hi, following situation: tests.dll contains a bunch of unit tests program.exe contains some to be tested classes tests.dll contains tests using the classes in program.exe therefore tests.dll has a reference on program.exe nunit-agent.exe loads tests.dll and this then loads program.exe --> basically in the nunit environment program.e...