nunit

How to exclude ancestors when calling Assert.IsInstanceOfType?

We've just separated our SQL Server database adapters to allow for differences between SQL Server 2000 and 2005, specifically, the nvarchar(max) data type. Because the code change is so small, instead of reimplementing our adapter interfaces and abstract base class, I subclassed the SQL 2005 adapter from SQL 2000 and just override the a...

How to migrate a nunit-config-file to mstest?

I would migrate all my unit tests from nunit to mstest. In the solution I have a nunit-config file, which looks like that: <NUnitProject> <Settings activeconfig="Web"> <Config name="Web" appbase="Web" configfile="web.config" binpathtype="Auto"> <assembly path="bin\Product.NUnit.ComponentA.dll"/> <assembly path="bin\Product.NUnit...

Accessing UI Thread in nunit

I am trying to write a test case where I have to access UI Thread. Does Nunit provide a way to access the ui thread or is there anyway I can execute some code on UI Thread in my test case. Thanks Update: I'm using winform. The usual way is to have the presentation layer and write the test cases against it but in this situation I have a ...

Making VS2008 tests into NUnit tests

I have been told that the automatically generated tests in VS2008 can be made compatible with NUnit just by adding #if !NUNIT using Microsoft.VisualStudio.TestTools.UnitTesting; #else using NUnit.Framework; using TestClass = NUnit.Framework.TestFixtureAttribute; using TestMethod = NUnit.Framework.TestAttribute; using TestInitia...

Can I create a wrapper around NUnit, MbUnit, xUnit or other testing framework?

How can I create a wrapper around a testing framework? We still doesn't know which testing framework are going to use, but I need to start writing unit tests. With this question I want to know how can I switch from NUnit to mbUnit, xUnit or even MSTest. ...

How can I make a generic unit test for all my classes that inherit from a base class?

I am creating a base class (or base entity) since all my database tables will have a companyID field. In my unit tests, I have to make sure the companyID value is correct. If I am returning a list of objects, all the companyIDs should be the same. Is there a generic way of me writing a test that will loop through all the values, that ...

Does MSTest Have an Equivalent to NUnits TestCase

I find the TestCase feature in NUnit quite useful as a quick way to specify test parameters without needing a seperate method for each test. Is there anything similar in MSTest? [TestFixture] public class StringFormatUtilsTest { [TestCase("tttt", "")] [TestCase("", "")] [TestCase("t3a4b5", "345")] [Tes...

How can I debug a NUnit unit test using resharper?

I am running VS2008 with Resharper 4.1, NUnit 2.2.7, coding in c#. I would like to use an NUnit unit test as a debugging harness while I am developing the code. My test is in a different project than the method being tested, but in the same solution. I have put breakpoints into the unit test as well as the method being tested. VS is ...

How to test if a button click opens a new Form with NUnitForms?

Hi, I'm new to C# and trying to write a simple GUI Unit Test with NUnit and NUnitForms. I want to test if a click on a button opens a new Form. My application has two forms, the main form (Form1) with a button that opens a new form (Password): private void button2_Click(object sender, EventArgs e) { Password pw = new Password(); ...

How do you get WatiN to work on Windows Server 2008 with IE8?

My problem is that I cannot get a simple WatiN test to reliably work on my development machine which is running Windows Server 2008 and IE8. I have seen a couple of good posts on this, but am still having problems. Here are the posts: MSDN Testing Article Stack Overflow - WatiN Second Method Fails The steps in the first article see...

What unit testing framework for .NET Framework 3.5?

Hello. I've a project in .NET Framework 3.5 and as i can see nUNIT does not support it yet. What unit testing framework would you recommend for my needs? ...

How to Unit Test Asp.net Membership?

Hi I am new to unit testing and I am trying to test some of my .Net membership stuff I been writing. So I am trying to check my VerifyUser method that checks if the users credentials are valid or not. So this is what it looks like: public bool VerifyUser(string userName, string password) { bool valid = Membership.Validat...

Filter on Category for NUnit MSBuild tasks?

I'm setting up a MSBuild project to run some NUnit test, using the MSBuild Community Tasks Project. With these settings I'll be able to run the NUnit tests: <Target Name="Test" DependsOnTargets="Build"> <CreateItem Include="$(ProjectTestDir)\$(ClassLibraryOutputDirectory)\*.Tests.dll"> <Output TaskParameter="Include" ItemName="Test...

Need Help understanding this code.

Hi I am trying to learn unit testing. I am trying to unit test some Memembership stuff I am making in asp.net mvc 1.0. I been following a book on MVC and I am confused about some stuff that hopefully someone can clear up for me. I am using Nunit and Moq for my frameworks. Question 1: public AuthenticationController(IFormsAuthentica...

Debugging with NUnit

I'm using NUnit for my unit tests and I have my unit test class library project setup so that Visual Studio launches the NUnit gui when I press F5. This lets me set breakpoints in my tests and look at the contents of variables, etc. What isn't happening though is that if one of my tests crashes (throws an exception) Visual Studio does ...

How to use external data in Unit Tests?

I've got lots of unit tests which needs lots of txt, data, html etc. files. Externally storing these files makes life so much easier to update test cases adding new test cases etc. However having dependencies in Unit Tests brings lots of headache in different systems and in different test runners. What are the best practices? Extern...

Is using NUnit's Sequential attribute a valid strategy to achieve one check per test?

Suppose I have several small test cases. Easy enough to setup and easy enough to execute. Suppose each small test case could perform multiple checks. As I buy into the fact that one test case should ideally check one condition, I believe to have a few options to implement such a requirement. Create a base class with all the test cases...

Populating SQLite in memory for unit testing

I am thinking of using SQLite as an in memory stub for my Oracle database. I can easily direct all my DAL commands to the SQLite, but I am now wondering how I should easily populate the data for each test method. Should each method begin by creating the needed table(s) and inserting the rows for the specific test? Should I populate in th...

Implement Unit Testing on a legacy web site

Hi All, I downloaded nUnit and TestDriven.net. I have a legacy Web Site application and I would like to implement some unit testing. I created a class in the app_code folder and added Imports NUnit.Framework etc... After writing a basic test, I get the "Can't execute tests in 'Web Site' application." error. I guess the Web Site project i...

IE hangs up during execution of Tests through cc.net

I am experiencing IE hangup since long. When I execute my tests through nunit directly, it works fine. but when I try to execute them through cc.net they seems to hangup at some point and without any reason. It stops the execution of all tests at that point. And even dont run the teardown fixture in which I am closing IE. Can anyone pl...