nunit

Multiple asserts in single test?

Let's say I want to write a function that validates an email address with a regex. I write a little test to check my function and write the actual function. Make it pass. However, I can come up with a bunch of different ways to test the same function ([email protected]; [email protected]; test.test.com, etc). Do I put all the incantations t...

How do you write to the Log tab and Console.Error tab of the NUnit gui runner

In the NUnit Gui Runner, there are 6 tabs. I can write to the Console.Out by writing something like: Console.WriteLine("This will end up in the Console.Out"); I can write to the Trace tab by writing something like: System.Diagnostics.Trace.WriteLine("This will end up on the Trace tab"); But how do I write to the two other tabs, "...

What is each tab in the NUnit Gui Runner supposed to be for?

There are six tabs in the NUnit Test runner: Errors and Failures Tests Not Run Console.Out Console.Error Trace Log I know what Errors and Failures are for but the purpose of the remaining tabs is confusing. Both Console.Out and Trace appear to serve a similar purpose. As a comment has pointed out, I have written a similar question...

Unit/Integration Testing code that uses HttpCurrentContext

Trying to get Nunit working in ASP.Net. The problem is, I'm testing a custom control - which references a Global Resource. When I try to unit test it /// </summary> [Test] public void TestSetAndGetNumber() { PhoneNumber phone = new PhoneNumber(PhoneNumber.NumberType.Business, "", true, ""); ...

How to make a .NET process run out of memory without exhausting all system memory.

The problem is simple I have a process, that does ETL on some xml files. We started getting really large xml files and I started getting OutOfMemoryExceptions. Fixing the process is relatively simple. However, I'd like to make a unit test for my NUnit suite to make sure the process will continue to be able to handle really large files. ...

How can this code throw a NullReferenceException?

I must be going out of my mind, because my unit tests are failing because the following code is throwing a null ref exception: int pid = 0; if (parentCategory != null) { Console.WriteLine(parentCategory.Id); pid = parentCategory.Id; } The line that's throwing it is: pid = parentCategory.Id; The console.writeline is just to ...

Is there a way to declare timeout period with NUnit?

I would like to be able to fail the test if the executing code hangs. Is there a way to do this currently? I am thinking something like the following must exist, but I can't seem to find it in the API [Test, Timeout(TimeSpan.FromSeconds(2))] public void Test() { ...} ...

How do I disable images and Flash from loading when using Selenium with Firefox?

When running selenium tests through Selenium RC in Firefox 3, the instance of Firefox that launches to run the tests in always displays images even though I've setup Firefox 3 to not display images. Do anyone know how to disable the images from loading? I'd also like to disable flash from loading on the test pages as well. ...

Visual Studio integrated custom MSBuild task behaviour

I was looking around the net for a NUnit custom MSBuild task that would run on every build and also nicely play with Visual Studio UI (2008 is my version). I found MSBuild.Community.Tasks project that was great, but failed in Visual Studio integration part. What I actually wanted to have is get failed tests displayed as warnings/errors i...

output the name of the current test via use of code in [Setup] method

I've current got a line at the top of all my tests that looks like this: Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name); Seems like it'd be nice if I could just put this in my Init method (the one tagged with [Setup]). I thought this would work but no matter what number I put in for the stack frame the closes...

is it reasonable/possible to use Nunit's Configurations to change test behavior?

I've got a suite of about 20 tests that I run on my Development server. I'd like an easy way to switch over to the Alpha server and run those same 20 tests. But I don't want to run them on all servers every time. Typically I'd run the tests on Dev until they are all green, then roll code to Alpha, run tests, etc. Many iterations on Dev, ...

Automated Publish of Developer work using cc.net

I want to build a developer build project and then needs to publish it to the server and After a successful publish need to build my test project against that developer publish. Basic idea is to run this process whenever any developer commits something on Svn. Currently I am using CC.net and MSBuild. Any one ahaving idea how to accompl...

NUnit example code?

I would like to learn how to use NUnit. I learn best by reading then playing with real code. Where can I find a small, simple C# project that uses NUnit in an exemplary manner? ...

How do I unit test for machine specific behaviour?

I am testing a static method that builds a URL string after checking proxies and hostnames and all kinds of things. This method internally relies on the static flag System.Net.Sockets.Socket.OSSupportsIPv6. Because it's static, I cannot mock this dependency. EDIT: (This is simplified down a lot... I can't modify the structure of the met...

Dynamically create tests in NUnit

Using Nunit, I want to be able to write a test fixture that will read all the filenames in a particular directory and create a test for each file. I could quite easily write one test method that scans through the directory and just does all the tests, but when I run NUnit I want to be able to see each of the tests individually. Is this...

Help running NUnit from dos command line.

I am working on an MSBuilds script to run my NUnit tests from CruiseControl.Net. _Test_DAL has three tests in it. I am having problem getting the right dos command to run the NUnit. Here is the command to run NUnit but it does not find any tests. D:\CC\JCDCHelper\Source_Test_DAL\bin\Debug>"C:\Program Files\NUnit 2.4.3\bin\nun...

Unit Testing the Data Access Layer - Testing Update Methods?

I'm looking into adding some unit tests for some classes in my data access layer and I'm looking at an update routine that has no return value. It simply updates a row based on the id you provide at whichever column name you provide. Inside of this method, we collect the parameters and pass them to a helper routine which calls the st...

Nunit integration in a window application in VS2005 using C#

Hi, I'm developing a window application in VS2005 using C#. I need to integrate NUnit into my project. Mainly i need to implement the 'Execute' option available in NUint. How can i do this.? ...

specifying path in nunit-console

can i specify the path of the dll to run in the nunit-console if so how to do it . what i do normally is that in command prompt i give nunit-console testassembly1.dll here test assembly1.dll is present in the same path as nunit-console.exe but can i run dll in different path .if so how ...

Where does nunit store recently loded assemblies

When we open NUnit application it loads the assemblies that are loaded in it previously. Where does nunit store those recently loaded assemblies.? ...