.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Post New Web Links

NUnit

Posted By:      Posted Date: August 21, 2010    Points: 0   Category :ASP.Net
 

Im pretty new to NUnit and am beginning the process of setting up my tests.  Some of these test involve a database, specifically checking a particular value against a value in a database and if its not greater than the last retrieved value, flag an error.  Whats the best way to test in this scenario ?  should I write one value to a database then create another value thats out of sequence and run a database query ?  This would involve putting a known value into the table, then running the query with another value.

There is no rollback attribute for nunit, so I gues using TransactionScope would work, that way I could return the database to a known state after the test.  There tables have foreign keys so that means adding a lot of extra 'dummy' data first to some of the other tables.  Is this sort of 'testing' the best way ?  I basically need to perform the test based on an existing data value and I guess this must be pretty standard stuff, so whats the best way ?


As I understand it, the tests should be self contained, so any data i insert into the database during the test should be removed afterwards, is this correct ?  If so, it means I need to insert test data into 6 additional tables just to test one function, then remove it after the test has completed, is this the normal way to to this ?




View Complete Post


More Related Resource Links

reading values from config files in NUnit tests

  

One of my NUnit tests has to read in some values from config files.  In my main application this process works perfectly well, however when I run the unit test, the code that reads in the values from the config files doesnt read anything in.  Ive tried putting app.config in my unit test project (I even tried web.config) but nothing seems to work.  Are there any special steps involved when reading from config files in an nunit test ?


NUnit and public static readonly

  

I have an app that I am testing with NUNit.  The project im testing has several helper classes that are created as public static readonly.  When I run the NUnit tests, they all fail with the same error


Systems.Code.Test.TransactionTest.CreateDataContext_ConnectionString_ReturnsDataContextObject:
SetUp : System.TypeInitializationException : The type initializer for 'Systems.Utils.ConstantHelpers' threw an exception.
  ----> System.NullReferenceException : Object reference not set to an instance of an object.
Systems.Code.Test.TransactionTest.CreateDataContext_ConnectionString_ReturnsDataContextObject:
SetUp : System.TypeInitializationException : The type initializer for 'Systems.Utils.ConstantHelpers' threw an exception.
  ----> System.NullReferenceException : Object reference not set to an instance of an object.

I kept getting this error despite stripping out all

NUnit and config files

  

Ive created an NUnit test project in my solution and have added 3 tests.  They all fail with the same error


Systems.Code.Test.TransactionTest.CreateDataContext_ConnectionString_ReturnsDataContextObject:
SetUp : System.TypeInitializationException : The type initializer for 'Systems.Utils.ConstantHelpers' threw an exception.
  ----> System.NullReferenceException : Object reference not set to an instance of an object.

Systems.Code.Test.TransactionTest.CreateDataContext_ConnectionString_ReturnsDataContextObject:

SetUp : System.TypeInitializationException : The type initializer for 'Systems.Utils.ConstantHelpers' threw an exception.

  ----> System.NullReferenceException : Object reference not set to an instance of an object.


heres the test method


[Test]
        public void CreateDataContext_ConnectionString_ReturnsDataCon

NUnit debugging no longer working

  

Hi,

I moved from VS2008 running on XP 32 bit to VS2010 running on Win7 64 bit and just noticed that I can't debug in NUnit like I used to.

On my old system, I just went to Debug|Attach to Process, chose NUnit.exe, and ran my tests from the NUnit GUI. VS2008 would stop at the breakpoints just as normal.

Now when I try this using NUnit 2.5.5.10112 on the new configuraiton it just skips over my breakpoints. Any help would be great.

Thanks,

John


How to make NUnit execute only a specific test

  

I set Nunit to run automatically when I run my class library project like this

/fixture:abc.Integration.Tests /runselected abc.Integration.Tests.dll

 

When I run in class library project, it starts running all the test in Nunit Test project. How do I specify 'exact one' test which I want to be run instead of all tests or last run tests?


SP 2010 Web Testing using MSTest or NUnit with Selenium

  

Hi

 

I am trying to define and setup web testing for my current SharePoint 2010 portal. I just wondered if anybody in the dev community has done this using products like Selenium (RC or Grid). If so, did you also use NUnit or MSTest with Selenium?  I am thinking of using TeamCity for my CI Server so again I am looking at compatibility issues. Most posts on the web appear to be using NUnit with Selenium if regression or load testing.

I am also considering the Load tester ( part of the SP2010 Admin Toolkit) with TFS .....

 

Regards

 

Daniel  


Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend