text: This article is an attempt at creating some documentation regarding NUnit and MonoDevelop. I decided to create it after an exercise in futility searching the Internet; maybe there is documentation out there but I couldn't find it. This article is based on NUnit 2.2.8.0 and MonoDevelop 1.0 running on UbuntuStudio 8.04. What was most confusing to me is that MonoDevelop has a project template called “NUnit assembly test collection”; if anyone can shed light on how or what that is used for, I'd love to update this article or link to another. In summary, it's not exactly obvious how to use NUnit with MonoDevelop and I'm not sure this is a best practice but it worked for me.
  One thing I did come across as far as guidance is that it's recommended to have a test project for each project in a solution. Personally I like this concept because it clearly and visually separates the test from the real code. Whether or not you include the test projects in the same solution or not is up to you. Follow these simple steps to get started unit testing your code. Keep in mind this is by no means a comprehensive unit testing article. If you're reading this, I'm assuming you know what unit tests are and why you should use them.
  In this example, we are going to create a console application, add a library and a unit test for that library.
  MyLibraryTest
  MyClassTest
  MyLibraryTest
  MyLibrary
  nunit.framework
  using
  using System;
  using MyLibrary;
  using NUnit.Framework;
  [TestFixture]
  MyLibrary
  public int Divide(int number1, int number2)
  {
  int result;
  try
  {
  result = number1 / number2;
  }
  catch(DivideByZeroException)
  {
  result = -1;
  }
  return result;
  }
  Add the following method to MyClassTest:
  [Test]
  public void DivideTest()
  {
  MyClass mc = new MyClass();
  int result = mc.Divide(12, 6);
  Assert.AreEqual(2, result);
  //
  // Dividing by zero should result in -1 since the function handles this case.
  result = mc.Divide(0, 22);
  Assert.AreEqual(-1, result);
  }
  Execute your test:
  So in conclusion, it's relatively easy to get started down the path to TDD using NUnit and MonoDevelop. I hope that someone from NUnit and/or MonoDevelop might read this article and say “you nailed it!” or “this is complete rubbish”. Either way I hope you find this article useful enough to get started. Also, any feedback that you can provide is much appreciated. Happy coding!
  Download the zipped code sample from here and open it with MonoDevelop.
  I discovered that MonoDevelop 1.0 doesn't have a built-in debugger. Apparently you can get an addin but I recommend waiting for MonoDevelop 2.0 which is due to be out this year. Here is a list of features.
  One thing I noticed on Ubuntu is that MonoDevelop 1.0 crashes a lot. I'm not sure if that has to do with the unit testing I was doing, but I hope that 2.0 is more stable.
  I noticed that even though there is a catch for a divide by zero exception, the test still fails. Can you figure out why?
  This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)
  sudo apt-get install monodevelop-nunit
  General News Suggestion Question Bug Answer Joke Praise Rant Admin
  Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.