nunit

What is the correct way to implement the NUnit 2.5 Constraint.Write*() methods?

Hello: I'm planning to implement my own set of constraints, and am having some difficulty understanding how to implement the following methods of the Constraint class. public abstract class Constraint { public abstract void WriteDescriptionTo( MessageWriter writer ); public virtual void WriteMessageTo( MessageWriter writer ); ...

TestDriven.Net Only Running One Test Fixture In File

I'm using NUnit (but have also tried this with VS testing) and I'm having a problem getting TestDriven.Net to recognize and run different test fixtures in a single .cs file. I'm trying to do a little BDD style testing. So what I have in one file is something like this: [TestFixture] public class when_view_is_ready : AAA { // setup,...

How does I use ExpectedException in C++/CLI NUnit tests?

How do you do the equivalent of: [Test, ExpectedException( typeof(ArgumentOutOfRangeException) )] void Test_Something_That_Throws_Exception() { throw gcnew ArgumentOutOfRangeException("Some more detail"); } ...in C++ (the example there is C#)? As far as I can see, there's no typeof() function for the C++ implementation of NUnit. ...

Unit tests with mock verifies

I have a unit test that creates a mock calls my method to be tested (also injecting my mock) asserts method results verifies mock calls When mock calls don't verify as expected I get an exception, thus failing a test. How should I correctly call this verifies? Should I just be calling // verify property get accessor call m.VerifyGet...

TDD - Test Existence of Interface

Getting started with TDD and I want to ground up a Repository-driven Model. However, how can I use NUnit to effectively say: SomeInterfaceExists() I want to create tests for each domain model (E.g. ICarRepository, IDriverRepository), etc.) Does this actually make sense? Regards ...

How to report the progress when NUnit tests crashes on a CruiseControl.NET server?

Nunit works quite well with CruiseControl.NET, but there is one thing that irritates me a lot. If there is a test that causes Nunit to crash, I would only get little information about the crash because the XML report of Nunit doesn't get a chance to be created and be merged into the CruiseControl report. I need a way to report the progr...

Best practices for setting up a Visual Studio project for nUnit tests

How do people set up their projects for Visual Studio and how do you reference the testable application ? Right now I've added a separate project creating a .dll to my solution which contains all the test cases and references nunit.framework , and it also references the main .exe file right from the Debug/ folder where VS generates the ...

NUnit test runner GUI that easy can load multiple DLLs

We have loads of DLLs with tests. I'm looking for a test runner (GUI) that either allows me to load all DLLs in a folder or that can load all tests from Visual Studio solution files. Ideas? (I would like to use it as a complement rather than a replacement to our nightly builds (that runs all tests)). ...

Testdriven.Net And NUnit Exception

Recently something happened to my TD.Net environment. When running tests with TD.Net, its looking for nunit 2.4.6. This happens with any project that uses NUnit as my testing framework. No references to that version in any of my projects. Have un-installed / re-installed both the latest NUnit and TD.Net several times. TD.Net works fine ...

What is the best way to unit test a protected method in C++?

What is the best way to unit test a protected method in C++? In Java, I'd either create the test class in the same package as the class under test or create an anonymous subclass that exposes the method I need in my test class. Because neither of those methods are available to me in C++, what are suggested approaches for testing pr...

Why does my nant task fail on CruiseControl (can't find nunit)?

My nant script fails when I run it under cruise-control on (Windows Server 2003), but works fine when run on the console. nant script (relevant section): <target name="compile" depends="init"> <echo message="Build Directory is ${build.dir}" /> <exec program="${framework::get-framework-directory(framework::get-target-framework()...

NUnit - cleanup after test failure

We have some NUnit tests that access the database. When one of them fails it can leave database in inconsistent state - which is not an issue, since we rebuild database for every test run - but it can cause other tests to fail in the same run. Is it possible to detect that one of the tests failed and perform some sort of cleanup? We do...

Can't test with NUnit on Vista 64bit

Hello, I encountered the problem while trying to run unit testing with NUnit 2.5 in Vista 64bit, MS Visual Studio 2008 SP1, Projects framework 3.5. I have 2 projects in solution, the first - main project and the second - project with tests. Both projects targeted "Any CPU" platform. In fact, I didn't changed anything concerning platform...

NUnit - Assert to check all properties are equal?

Is there an assertion built into Nunit that checks all properties between 2 objects are the same, without me having to override Equals? I'm currently using reflection to Assert each individual property for a pair of objects. ...

Launching NUnit from Visual Studio can't load nunit.uikit.XmlSerializers

I have set my Visual Studio to start Nunit as an external program to run all the tests written in a module. It gives me this error: Could not load file or assembly 'nunit.uikit.XmlSerializers, Version=2.5.0.9122, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77 but if I run it from command-line: nunit.exe Tests.dll it launches just fi...

How would you apply unit testing in this situation?

I have never written unit tests before, for various reasons. I have a chance to write tests now, comfortably, because I have a small app to make from scratch. However, I'm a bit puzzled. The application is supposed to use a printer with a smart card reader to program data on a smart card. So here's the sequence of actions: Create device...

Nunit .net vs mono

I have written a simple test application using asp.net mvc with C#. The application uses MySQL by using dblinq to generate linq to MySQL files and the application is working both in windows and linux. I have now started to use NUnit to test my code, mostly since I need to test if the code working under windows also will work in linux. M...

How do I write NUnit unit tests without having to surround them with try catch statements?

At my company we are writing a bunch of unit tests. What we'd like to have done is for the unit tests to execute and whenever one succeeds or fails at the end of the test we can write that somewhere but we don't want to put that logic in every test. Any idea how we could just write tests without having to surround the content of the te...

How can i skip the Setup method only for a particuler test in Nunit?

I have a test , where i do not need to run the setup method (attributed with [SetUp] ) before running the test.I need the setup method to be run for other tests. Is there any attribute/otherway of achieving this?Is this supported by Nunit? ...

Strange behavior in the "Verify" method in Moq

In the following code, Test1 succeeds but Test2 fails: protected Mock<IMyInterface> MyMock { get; set; } [SetUp] public virtual void Initialize() { MyMock = new Mock<IMyInterface>(); } [Test] void Test1() { // ... code that causes IMyIntervace.myMethod to be called once MyMock.Verify(x=> x.myMethod(), Times.Once()); } [...