nunit

nCover With many class libraries

So I have my project and it is set up like this: MyProject MyProject.Module1 MyProject.Module1.Tests MyProject.Module2 MyProject.Module2.Tests What I want is the code coverage number for the entire project. I am using nCover... what is the best way to do this? For example would I have to rearrange the project and have everything put ...

What testing framework for c# is the most similar to Junit 4?

Mainly from feature-set standing point, as well as similarity of method names/working logic/verbosity ? ...

How can I get DevExpress CodeRush to create NUnit test methods with the tm template instead of microsoft test methods in VS 2010

Hello, when I try to execute the test or testmethod templates respectively in visual studio 2010 using t and tm respectively it is giving me ... using Microsoft.VisualStudio.TestTools.UnitTesting; [TestMethod] public void Test() { } I want it to give me the nunit decorator instead and stop adding the using refere...

How to set up an NUnit project - Project Base and Application Base

Please forgive a very n00b question, but when using the GUI runner, Project->Edit... What directories should Project Base and Application Base point to? (Using the latest NUnit 2.5.7 and a VC# 2008 Express solution.) ...

NUnit won't load my unit test .dll file.

I'm following the book Pro ASP.Net MVC2 and I can't move past this point. What would cause this error? Why does it say 'load an assembly from a network location' when my .dll is on my machine? ...

NUnit error at index -1

I'm attempting to NUnit test adding an element to a collection from a new thread. This is the test function I'm using: [Test] public void WorkerThreadAccess() { string foo = "Foo"; Collection<string> collection = new Collection<string>(); System.Threading.Thread thread = new System.Threading.Thread(() => colle...

API strategy of known .Net projects

I am writing an API for my application and have a few open questions (with versioning in mind). Should users call directly my objects or need I provide some abstraction? Should code that users wrote with version X of the API only work with version X or should it work also with the latest version? Initially I thought "abstraction" and...

Teamcity CI build nunit test not reading app.config file

I have a teamcity install that runs a series of unit tests. I added an app.config file so that the library being tested can pull test config data. This works well when using the nunit GUI on my dev box. On the CI server however the n-unit tests fail because the app.config file is not being read. Is there something I need to do in team ci...

VS2010 + NUnit failing to load assemblies?

Im using VS2010, C# 4.0, NHibernate and NUnit in a project Im working on.. In doing database tests I've come across a wierd problem.. When I run my tests, nunit-agent.exe crashes for no apparent reason.. I've since then discovered that when i debug my tests, I get the following exception in the TestFixtureSetup method: TypeInitializa...

unit testing failing when run in batch

I am new to unit testing. I have created various tests and when I run test each one by one, all tests passing. However, when I run run on the whole as a batch, some tests failing. Why is that so? How can I correct that? ...

How to include inside method

I don`t want to use the [ExpectedException(ExceptionType = typeof(Exception), ExpectedMessage = "")] instead would like to include the exception inside my method. Can I do that? Any example please. Thanks ...

Having trouble getting started with Moq and Nunit

Hi all, Banging my head against a wall trying to get a really simple testing scenario working. I'm sure I'm missing something really simple! Whatever I do, I seem to get the following error from the NUnit gui when running a test against my DLL: System.TypeLoadException : Type 'Castle.Proxies.ITestProxy' from assembly 'DynamicProxyGenAs...

Visual Studio and NUnit - automatic running of unit tests on build

I would love to know if there is a way I can get Visual Studio to run unit tests corresponding to a given assembly whenever I build it. Given a solution containing projects structured like this: Assembly1 Assembly1.Tests Assembly2 Assembly2.Tests Is there a way I can get the unit tests in Assembly2.Tests to run whenever Assembly...

Pointers for writing a unit test for a Razor based View needed.

I'm trying out the new Razor view engine with MVC 3 Preview 1 and would really like to write a simple unit test using NUnit/Moq. I haven't seen any examples of this actually being done yet - despite it being one of the real selling features on Razor. So, if I have a Controller, that uses a DBConext object (EF4 CTP code first) and the vi...

NUnit: abort test if it takes too long

Is there a nice and simple way to get NUnit to kill a test that takes more than a specified amount of time? Ideally it would not only kill the app domain in which the test was running, but also any child processes the test started. ...

How can I use NUnit to test a method with out or ref parameters?

If I have a function which accepts an out parameter and accepts an input form console - public void Test(out int a) { a = Convert.ToInt16(Console.ReadLine()); } How can I accept an input using Console.Readline() during NUnit test? How can I use NUnit to test this method? I tried using this code for my NUnit test case - [Test...

How can I fake HttpContext for unit tests?

Hello, I need to fake HttpContext.Current.Application table to access it from my unit tests. I need to store my data somewhere. I thought that I can just pass instance of NameValueCollectionBase but as I descover this base type has no indexer so it's too complicated to use. So what about faking this part of HttpContext? Is it possib...

Cannot Drop Database after Unit Test

ANSWER: I wasn't clearing my ConnectionPools. The solved scenario is: SetUp: Check to see if the 'TEMP_NUnit' database (SQL Server 2005) exists on the local instance If it exists, drop it. Create a new blank database named 'TEMP_NUnit'. Test: Instantiate the 'Upgrade Database' component. Check that essential properties of compone...

TeamCity NUnit integration failing - Always getting "Could not locate the assembly nunit.framework..."!

Hi, I'm trying to get TeamCity to run NUnit tests as set up in an NAnt script as follows: <nunit2> <formatter type="Xml" usefile="true" extension=".xml" outputdir="${BuildArea.ReportsDir}" /> <test assemblyname="${BuildArea.OutputDir}\Common.Tests.dll" appconfig="s...

Testing Attribute Behavior

Hi, I’m using SharpArch with SharpArch.Contrib’s [Transaction] attribute. The Transaction attribute is added to an application service method and if an exception is thrown during that method then any changes to any domain objects are rolledback. From all appearances this works well. However, I’m writing NUnit tests to confirm that ex...