nunit

How can I create NUnit tests with ReSharper?

Hi, I'm trying to get into unit testing with C#. Various people told me to go with NUnit since it's better than MSTest (apparently, I have no idea) and it also has very good support in ReSharper which I'm using. Now I've never written a unit test before in my life (bear with me, I'm a university student). ReSharper has this nice Create...

Testcase using NUnit

Folks, I am new to writing testcases for the methods. Here I have a InsertMethod for which I want to write testcase using NUnit testing framework. Help me in writing the testcase for the method below : public bool insertUser(String FirstName, String LastName) { bool result = false; SqlConnection myconn = new SqlConnect...

How to mark a whole class as "Inconclusive"?

Hi, I've a test class named MyClass. MyClass has a TestFixtureSetUp that loads some initial data. I want to mark whole class as Inconclusive when loading initial data fails. Just like when somebody marks a test method Inconclusive by calling Assert.Inconclusive(). Is there any solution? ...

Nunit2report generates multible reports

I'm running nant and used nunit2 to generate a xml result file per assembly. My problems is when i use nunit2report the generate reports has dublicated its self by the number of assembly result files. Does anyone know where i went wrong portion of my nant script: ` <nunit2 failonerror="false" verbose="true"> <formatter type="Xml" ...

How to NUnit test for a method's attribute existance

public interface IMyServer { [OperationContract] [DynamicResponseType] [WebGet(UriTemplate = "info")] string ServerInfo(); } How do I write an NUnit test to prove that the C# interface method has the [DynamicResponseType] attribute set on it? ...

Noshadow option for nunit-console

I have following question : what are advantages and disadvantages in running nunit-console with /noshadow option? Your comments will be very helpful Thanks ...

using nunit with visual web developer 2008 express

I'm experimenting with potentially using Visual Web Developer 2008 Express for a project, but since the Express edition doesn't support the publish feature and since the ide also does not create any *proj files, how can I use the nunit gui to run my tests? ...

C#: How to test for StackOverflowException

Say you have a method that could potentially get stuck in an endless method-call loop and crash with a StackOverflowException. For example my naive RecursiveSelect method mentioned in this question. Starting with the .NET Framework version 2.0, a StackOverflowException object cannot be caught by a try-catch block and the correspondin...

How to unit test code that is highly complex behind the public interface

I'm wondering how I should be testing this sort of functionality via NUnit. Public void HighlyComplexCalculationOnAListOfHairyObjects() { // calls 19 private methods totalling ~1000 lines code + comments + whitespace } From reading I see that NUnit isn't designed to test private methods for philosophical reasons about what unit ...

Bug/issue tracking integration with Cruise control

Hi everybody, I am putting together a bunch of applications to create an automatic building for microsoft platform (the products I chose and the software I will build, both, runs on windows). The products I've chosen are: Code repository: SubVersion Continuous integration: CruiseControl Unit testing: NUnit Test coverage: NCover Static...

WatiN IE browser and local javascript files using file:/// protocol

Hi All, I'm currently using WatiN to run some javascript unit tests however everything works fine if I initialise the WatiN IE browser like this: Browser browser = new IE("http://localhost/Project/tests.hyml"); However, as soon as I try to initialise the browser with a file uri, i.e.: Browser browser = new IE("c:\\\\Projects\\Projec...

Convert string to C# code

Hi, in the current NUnit version, I can parameterized TestFixture and instantiated it multiple times. E.g.: [TestFixture("var1")] [TestFixture("var2")] [TestFixture("var3")] public class MyTestFixture { private string var; public MyTestFixture(string var) { this.var = var; } ... ...

using nUnitASP in webforms

I am new in Unit Testing. I have been asked that nUnitASP can be used to test WebForms. and it is already integrated in VS2008. I am not able to find any way in VS2008 for unit Testing ASP Webforms specifically. Though I know the native method VS provide for UnitTesting, I am quite aware of NUnit using as seperate GUI. I am seeking for a...

Is there a way to prevent Visual Studio 2008 from opening a file in design view by default?

I'm writing an NUnit TextFixture for portions of a Windows Forms application. Some of the classes in the file are derived from UI component classes, like so: [TestFixture] public class MainFormTest : PersistenceTestBase // Base class here is not a form { class TestMainForm : MainForm // MainForm inherits from Form { pub...

NUnit Test - How to use it in your application

Can anyone tell me what is NUnit in .NET and how to use it? I have heard that using this tools improves design of an application. Is it true? Where can I get an absolute beginners tutorial on this topic? ...

C#, NUnit: Clear way of testing that ArgumentException has correct ParamName

To test that something throws for example an ArgumentException I can do this: Assert.Throws<ArgumentException>(() => dog.BarkAt(deafDog)); How can I check that the ParamName is correct in a clear way? And bonus question: Or would you perhaps perhaps recommend not testing this at all? ...

C#, NUnit: How to deal with testing of exceptions and deferred execution

Say we have a method that looks like this: public IEnumerable<Dog> GrowAll(this IEnumerable<Puppy> puppies) { if(subjects == null) throw new ArgumentNullException("subjects"); foreach(var puppy in puppies) yield return puppy.Grow(); } If I test that by doing this: Puppy[] puppies = null; Assert.Throws<Argumen...

Run NUnit tests automatically from command line

I'm launching the NUnit gui from visual studio by setting the test project to start start nunit 2.5.3 as an external program. That loads the tests into the GUI but I still have to manually click the run button. Is there a command line argument that will have the tests run at the same time they're loaded? ...

An Asserting Appender for Log4Net?

Is there a 'standard' way to introduce assertions against Log4Net output? E.g. NUnit.Log4Net.Checkpoint() ...run some code that should not throw warnings... NUnit.Log4Net.AssertNoErrors() NUnit.Log4Net.AssertNoErrorsOrWarnings() Or NUnit.Log4Net.Checkpoint() ...code that warns user about an obsolete value... NUnit.Log4Net.Asser...

How can I test for null arguments in the constructor of abstract class using rhino mocks?

I have a class like so: public abstract class ClassA<T> { protected ClassA(IInterface interface) { if (interface== null) { throw new ArgumentNullException ("interface"); } } } I want to write a test which verifies that if I pass null in the exception is thrown: [Test] [ExpectedExcep...