Posts Tagged ‘nunit’

Assert.Inconclusive and my present almost-TDD compromise

April 1st, 2011

I am trying out Visual studio unit testing framework, the Microsoft alternative to, for instance, nUnit which was my old preferred testing framework (and possibly still is).

At the same time I am not in a project devoted to Test driven development so I can’t use its religion to write tests first and refuse to show any UI progress to the customer.  Right or wrong – that is how I perceive the reality around me right now.  But I do want to have tests and waiting for them I make sure I have place holders.

My compromise is to set the tests to Inconclusive  (Ignore in nUnit talk).  I guess it will come back to bite me…

What I also do is to make sure I have a test to go with every method.

        [TestMethod]
        public void AddOrUpdateTest()
        {
            Assert.Inconclusive();
            Elvis.Common.Meta.GetMethodName<BLF.Sample>(x => x.AddOrUpdate(null, null));
        }

I used the code from

http://stackoverflow.com/questions/1524290/linq-is-it-possible-to-get-a-method-name-without-a-return-type-via-linq-expressio

but I could probably use CompulsoryCat just as well.

I belive that even adhering TDD this technique is good.  There are so many times I don’t know what the classes and methods will look like before having done a simple implementation.  To write exhaustive tests for a method that will be deleted is a waste.  Better then to make sure the simple code runs and not forget to write the tests by having a yellow Inconclusive flag.

Tools I use

July 28th, 2009

Below are the tools, sites and stuff I use.  I plan to update it as it goes.

Correction: I planned but haven’t.

Also: I have a shorter and similarly not-propertly-updated list as a article here.

7-zip
http://www.7-zip.org/
Even though I have a Winzip license I haven’t bothered installing it for several years.  I guess Microsoft killed Winzip through having simple zip support out of the box and for all other needs there are 7-zip.
Open source.
Winzip deserves an extra mentioning though due to their license: your payment is also valid for all updates.  Many many other software companies have something to learn there.

Agent ransack
http://www.mythicsoft.com/agentransack/
The built in searching software in Windows XP and forward sucks big time.  To its defense I must say that it searches Microsoft office documents.  But since it doesn’t search all folders it is rendered useless for a developer like me.  Agent ransack searches fast, very fast, and has a simple regex tool to refine searches. One can limit files and folders searched in and search in system files too.

Update:
The built in search in Vista is weird. It might work for office people, you know the kind that really can’t tell the difference between windows, word, internet explorer and internet. This search was probably updated for Win7 and very much so for Win8. But Agent ransack still has its use for really doing searches in files with regex and stuff.

Autohotkey
http://www.autohotkey.com/
This open source solution is handy for global shortcuts.  I use it to set the size of windows to cover half the left, right, top or bottom.  I also send my windows between my monitors with a similar keystroke.  It has a wierd scripting language and some bugs regarding how big monitors and windows are.

Update:
Sending the windows around between two or more monitors is done win Vista and later with window-arrow keys.

Connectionstrings.com
http://connectionstrings.com/

In Windows one have to have a connection string to connect to a database.  These come in all colours and tastes.  This site has a comprehensive list.  Gratis.

Dpack
http://www.usysware.com/dpack/
It is an addin to Visual Studio.  Gratis.  A must-have if you develop in Visual studio.
The most used shortcuts, for me, are alt-u to open files and alt-m to go to a method.  With this there is no more searching for files in the solution explorer or scrolling up and down looking for the right method.

Update:
Open source.
I still use it since Visual studio 2013 still hasn’t caught up. Not even with Resharper.

Filezilla
http://filezilla-project.org/
Filezilla is a free FTP server and client.  I only use the client.  I cannot say if it is the best of its crop or has some whiz-bang stuff that oushines the competition but it is free and fairly simple to use.

Keepass
http://keepass.info/
I have lots of passwords and so do most of us.  Instead of having the same password for most places or a system of passwords, use unique ones; then you don’t have to worry about people getting your hotmail because they got hold of the passwords for a small site somewhere and successfullly try it on hotmail too.
I have the same database synchronized with my Windows mobile phone; this requires an older version of the software unfortunately, but I keep the passwords with me without the need of a computer.
It is open source so you can inspect the source code at will.

Media-convert.com
http://media-convert.com/
A gratis site for converting all sorts of formats, not only video and sound.

MyGeneration
http://www.mygenerationsoftware.com/
I am a sucker for not writing code I don’t have to.  Automatic code generation is the way to go.
Open source.

Update:
T4 is a tough competitor.

Notepad2
http://www.flos-freeware.ch/notepad2.html
http://code.kliu.org/misc/notepad2/
I don’t think Notepad2 is the best editor out there.  Not even close really.  But it makes it easy to exchange your Notepad.exe with the vastly superior and open source Notepad2.  Notetab does the same pre WinXP and possibly many other editors too but this is the only I have tried (post win2k) and I use it.

Update:
I have since switched to Notepad++. Before that I used Notetab.

NUnit
http://nunit.org/index.php
Automatic testing is considered good.  I might be too much to test everything but the important things and the difficult things are worth while to test automatically.
Open source.

NUnitEx
http://code.google.com/p/nunitex/
This open source extension lib to NUnit makes it more fluent to write assertions.  The best return of investment is when writing tests for exception throwing.

Opera
http://www.opera.com/
This is my primary web browser and has been since before 2000.  For certain development things Firefox is better and one must have Internet explorer around for about one site a year but for the other 8759 hours Opera is to prefer.Web browsers are a pain to user with the keyboard.  Opera lets you navigate between the controls with shift-arrows; so much easier debugging when one doesn’t have to grab for the mouse all the time.
Gratis.

Opera mobile
http://www.opera.com/mobile/
Arguably the best mobile browser for fat mobile phones.  It is gratis.
For smaller phones I would use Opera mini that renders the web page in a farm and then sends just the result.  It doesn’t work with javascript heavy sites though.
There is an application, Skyfire, that I believe works like Opera mini. Don’t mix up Opera mobile and Opera mini.

Update:
Other mobile browsers has caught up.
A couple of years ago I did a comparison and couldn’t spot a winner.
As of today I believe Firefox mobile is the only one that supports Ghostery so right now it is used as much as Opera.

Pastebin.com
http://pastebin.com/
If you ever have tried sending a snippet over email or especially chat you know bad how the layout gets scrambled.  Enter Pastebin.
Paste the code into Pastebin and send the unique URL.  It even has history so when chatting you can update the code and resend.
Gratis.
There are competitors but I havn’t found any as good.

PDFCreator
http://sourceforge.net/projects/pdfcreator/
To create PDF documents I use an open source solution.  It installs itself as a printer so it is usable for everything from everywhere.  For reading I use OpenOffice instead of the competitor-for-the-worst-software-written-ever program from Adobe themselves.

PowerCommand for Visual Studio 2008
http://code.msdn.microsoft.com/PowerCommands
Gratis.  Source code available but I don’t know if there are any strings attached.
It has Copy reference and Open folder and Open command prompt.  No more tedious searching for references or walking all over the hard drive to find the correct folder.

Spam gourmet
http://www.spamgourmet.com/
An online solution for one time email addresses.  Good for avoiding spam.  It is gratis but it sometimes takes a while for the emails to pass through.Approximately the same result can be gained by having a spare email account for this but Spam gourmet comes with a number-of-possible-sendings solution that might be handy.

VLC
http://www.videolan.org/vlc/
There are many media players.  VLC is one of them.  I use it since it takes most formats.
It went version 1 in 2009.
Open source.There is another well known application, Media player classic, that does approximately the same.  To be honest, I use both.

Winmerge
http://winmerge.org/
This is an open source diff tool.  It has a nice keyboard navigation, something that the diff program that comes with Visual studio has totally messed up.  None of these two have any knowledge about classes and methods so if you swap two methods it is recognized as add and delete instead of the move it really is.
Somewhere I found a program that can diff 3 files at once but the URL is since long forgotten.

NUnitEx

July 22nd, 2009

NUnitEx is an extension to NUnit.  It makes the assertions more of a flow to write.

Instead of writing

string myString = MyMethod();
Assert.AreEqual( "selfelected", myString );

one writes

string myString = MyMethod();
myString.Should().Be.EqualTo( "selfelected" );

A good thing with the former approach is that the coloured syntax makes it easier to distinquish method calls from assertions.

But when one tests exception throwing nunitex is the way to go.

Originally one had to write one method per call that threw an exception.  Even as a happy typist I think it was too much.  Nunitex easily handles exception throwing calls almost as ordinary calls.

See the example code at http://code.google.com/p/nunitex/ for yourself.