Feeds:
Posts
Comments

Posts Tagged ‘nUnit’


So, I was tasked with testing a WCF service that publishes an interface for our customers to insert stuff into our database. The WCF service is an integrator and the functions allow customers to add their data in a controlled way without having to go through our main application. It’s quite useful as they can basically add data from any source they like and it is then correctly inserted and can be viewed in the main application.

We just had a new release and we changed how time is stored in the database. We went from local time to UTC. This is quite a major change but the users shouldn’t need to be aware of it. I made the changes to this WCF service and then it was supposed to be tested. That testing was never done and I got tasked with doing it, ASAP, it should be finished yesterday, get to work!

Anyway, started fiddling with nUnit to do integration testing.
Wrote a test, compile fine and went on to run the test in nUnit when I’m greeted by the following message:

(TestFixtureSetUp): SetUp : System.InvalidOperationException : Could not find default endpoint element that references contract 'NIS.TicketIntegrationServiceSoap' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.

After looking through app.config and it’s various locations I get the tip from a colleague to try associating dlls to nUnit and double click on it. Voila! Worked perfectly.

My friend told me that this has to do with working directory for nUnit. It seems this issue has been around for quite a while and is not yet resolved.

Read Full Post »


The setting
At work I got tasked with continuing maintenance and development of a web site. It uses asp.net, runs on .net framework 3.5 and was a horrible mess. All the code is in one file referenced by codebehind in the aspx-file. About 80% of the labels, grids, buttons and other components are named such things as Label1, GridView3, WebImageButton12.

Setting out
When I started I had the above project dumped in my lap. I had not worked with web development before, there was no handover and the one responsible had moved to London (I work in Sweden).
The first weeks I set out to try to understand the application and the incredible amount of noise, inconsistency and redundancy that it contained.
Time went by, I decided to finally get going with Unit Testing and started with reading The Art of Unit Testing to get the theory and some practical examples. After this I thought I was good to get going on Unit Testing and started a little in my own projects in Ruby. But still, there was this small threshold to get over.
Meanwhile I started reading Working With Legacy Code and after getting through the first two chapters I had broken down what little resistance there was left. Now I would get this monster under test.

So, I downloaded nUnit two days ago and started up. Well, I tried. I spoke to my good friend who has worked with Unit Testing for several years. I ran into some problems and asked him and when I said “It’s a website” he commiserated with me. So, I have to break the functionality out of the codebehind-file and test the buisness logic outside of the website and only use the codebehind to put things on the page. Since I’m in the middle of the release rush it’ll have to wait sadly.

However, when the release is over I’m unit testing this thing.

More to come when I get to it.

Read Full Post »


Art of Unit Testing

So, I recently decided that I would really start to get into unit testing and try out Test Driven Development. Where to start?

Personally I have trouble picking something up that I have no clue about. I can’t just sit down and start fiddling around with nUnit, or similar frameworks for unit testing, without quickly loosing motivation. It is very discouraging to know something should be possible but not know how, search on the net how to do it and then the next line run into the same issue. After a while I loose heart and then motivation gets shot down quickly after that.

I also find it quite hard to get best practices and all that knowledge about how things work from searching the internet. I like to be taken through the subject at a measured pace with a plan in mind.

In comes The Art of Unit Testing.

For a complete novice or for someone who has never worked with Unit Testing but knows some of the theory this is a good book to start with. For someone who has worked with unit tests and has a good grasp of unit testing this book is probably a bit basic even though I guess it could be a good way to review your skills.

The book takes it slowly from the start and builds all the way up to advanced concepts such as mocks, constructor injection and when to use stubs or mocks. It also gives tips on how to get a company to start using unit testing and a short chapter on how to get legacy code under test. It also lists the more important of the frameworks that are used with unit testing, such as testing frameworks, test coverage tools, dependency finder tools etc.

The book focuses on .net and primarily the nUnit-framework but people using other languages benefit from the techniques as these are usually applicable no matter what language is used.

A good and comprehensive read for those who are new to unit testing and a good review of skills for the experienced.

Read Full Post »