nunit

NUnit with Rhino Mocks exception: Why is it throwing this exception?

I'm getting an exception that really makes no sense to me whatsoever. I have an Expect call for a method that takes 3 arguments into it: The types are called CallContext, IDal, and List. NUnit throws me 2 exceptions: One for not expecting a method call that happened where the types are CallContext, System.Object, and List, and one fo...

nunit on release build: "Common Language Runtime detected an invalid program."

I upgraded our software from vs2008/.net 3.5 to vs2010/.net 4.0. All third party libraries (most relevant: nhibernate 2.1.2, spring 1.3.0, nunit 2.5.2) are still compiled using vs2008. When I run the unit tests for the debug build of our software, everything works fine. On the release build, nunit reports exceptions on 33 of 228 tests: S...

NUnit: How to test a private method with "ref"parameter in C#

I have a private method like below: int void SomeMethod(ref string theStr) { // Some Implementation } how to write the unit test case for this method. ...

Unit Testing with Nunit, Ninject, MVC2 and the ADO.Net Entity Data Model

I'm trying to get my head around using Nunit, Ninject, MVC2 and the ADO.Net Entity Data Model. Let's say I have have a ProductsController instantiating a SqlProductsRepository class. public class ProductsRepository : IProductsRepository { public MyDbEntities _context; public ProductsRepository() { _context = new My...

NUnit with VS 2010 is no longer stopping at breakpoints

The answer to this has got to be simple, but I sure don't see it. I'm working on an MVC2 project under VS2010, with Unit tests written in NUnit. I debug the tests (and code) by starting the NUnit GUI, then clicking Debug -> Attach To Process in VS, and attaching to nunit-agent. This has all worked fine for some time. I added one addi...

Moq controller tests with repeated setup

I am getting started on the Moq framework and absolutely love it. I am writing some controller tests that have several services and interfaces to Arrange my controller for the test. I'd love to modularize it a bit more, and thought this would be a trivial task, but it turns out to be a bit trickier than I thought. Here is one simple un...

Can an NUnit project load a separate *.config for each assembly that it loads?

If so, how? If not, what is the best workaround? Particularly, I'm trying to automate running unit tests in the GUI test runner on arbitrary developers' machines. ...

Open source alternative for TestDrive.net 'Visual Studio add in' for unit testing?

Hello I searched about this in SO and dint find a post on this. Since TestDriven.net is ONLY free for personal use, is there any other open source visual studio add in available for running NUnit test cases? Thank you. NLV ...

Help me avoid this NullReferenceException (using Rhino Mocks)

I'm currently trying to get one of my unit tests to work, but there is one thing in the way. I have a class called AccountingScheduleLookup that has an ID field attached to it that's read-only. When I try to mock a call to a method that uses this ID field it throws me a lovely NullReferenceException on that particular line of code. This ...

Web ui (ASP.NET based) to run integration tests written for NUnit

I want to be able to run and see the results of NUnit-based integration tests using some ASP.NET based UI (as opposed to regular windows based NUnit GUI). Is there an open source or commerical package already available? Note I'm not talking about testing ASP.NET or web apps.I want to run tests in code behind but see the results in Web br...

Using MVCContrib.TestHelpers with MsTest - is there any way to get nicer fail messages?

I'm just starting to use MVCContrib, and I'm really liking the syntactic sugar it adds to various test scenarious. For example, I just wrote this assertion: "~/".Route().ShouldMapTo<SpotController>(c => c.List()); It's brilliant! Well, almost... Instead of, as I'd like, seeing the actual reason why the test fails (I've changed nothin...

xUnit or NUnit? What advantages and disadvantages of each other?

Hi Guys, what is pluses and minuses of each framework, comparing to each other? How well they work with ASP.NET MVC? How well they support mocking? ...

Unit test behaviour after exception is thrown?

Hi all, I am just starting out with unit testing and have a scenario I'm not sure how to appraoch and my solution doesn't feel right. I have a bit of code that does something, if it fails i.e. throws an exception the exception is caught and logged as below. public T CreateTypedObjectInstance<T>() { T o = default(T); try ...

CruiseControl.Net, MSBuild and NUnit

The CruiseControl.Net documentation advises against using the NUnit task, suggesting instead that NUnit is called within the build script. I'm trying to work out what is the best way to achieve this. I've added a 'RunTests' project to my solution which uses the NUnit MSBuild Community Task to execute the tests. I wanted to add a 'Test...

selenium rc unable to click on a link

Hi, I'm facing a kinda weird problem today. Selenium appears to click on a link in one test case, but, ignores the same link in the subsequent case. This happens with any permutation-combination of test cases. Whichever case run 2nd, fail due to the above problem. can anyone suggest a solution for this?? I've tried selenium.click and se...

Unittesting database library in C# and NUnit

I have recently begun using NUnit and now Rhino Mocks. I am now ready to start using it in a C# project. The project involves a database library which I must write. I have read that test should be independent and not rely on each other nor the order of test execution. So suppose I wanted to check the FTP or database connection. I woul...

One for the NUnit gurus: Upgrading to 2.x and using new features with existing testing harnesses

I've recently upgraded to NUnit 2.5 (yeah I know) and I was wondering if I could pick someone's brain with this. I have lots of tests that look like this: [Test] public void TestTheSpecialDict() { int start = 0; int end = 44; Dictionary<int, string> = SomeFunction(start, end); Assert.That(dict1.Count > 0); // Alr...

How can I get StructureMap's AutoMocker to mock fake data?

I'm currently trying to implement StructureMap's AutoMocking functionality and I need help with getting the mocked . I have a Test method as follows: [Test] public void DirctoryResult_Returns_Groups() { var autoMocker = new RhinoAutoMocker<GroupController>(MockMode.AAA); GroupController controller = autoMocker.ClassUnderTest; ...

How can I run NUnit tests in parallel?

I've got a large acceptance test (~10 seconds per test) test suite written using NUnit. I would like to make use of the fact that my machines are all multiple core boxes. Ideally, I'd be able to have one test running per core, independently of other tests. There is PNUnit, but it's designed for testing for threading synchronization issu...

How to prevent 'over-testing' in a test case? (C#/nUnit)

I'm working on some test cases at the moment, and I'm regularly finding that I'm ending up with multiple asserts in each case. For example (over-simplified and comments stripped for brevity): [Test] public void TestNamePropertyCorrectlySetOnInstantiation() { MyClass myInstance = new MyClass("Test name"); Assert.AreEqual("Test Name",...