Specifying Custom NUnit Runner in MonoDevelop

2015/11/18

I just discovered that the NUnit Add-In in MonoDevelop has a nice although undocumented feature: you can specify a custom test runner in the .csproj file, either as an executable or as a type. If you have the NUnit.Runners nuget package installed in your solution/project and you want MonoDevelop to run the unit tests with nunit-console.exe instead of the built-in runner, you can add the following to your .csproj file:

   </PropertyGroup>
     <TestRunnerCommand>packages/NUnit.Runners.Net4.2.6.4/tools/nunit-console.exe</TestRunnerCommand>
   </PropertyGroup>

Now when you run your unit tests in MonoDevelop they will be run by nunit-console. This is useful when your unit tests make use of features that the NUnit Add-in doesn’t support yet, like ActionAttributes.

The other tags that are supported are:

  • TestRunnerArgs: Allows to specify additional command line arguments to the TestRunnerCommand
  • TestRunnerType and TestRunnerAssembly: allow to specify a test runner class/type and the assembly where to find this type.

If both TestRunnerArgs and TestRunnerType are specified, TestRunnerArgs takes precedence.

Tracking undisposed objects

2014/10/29

Every so often I come across a crash or a hang in my project or unit test that is caused by missing dispose calls. This is especially true if a managed object holds references to COM objects and even more so if it’s not thread-safe. Since garbage collection runs on a different thread the finalizer gets called on that thread as well, often causing trouble.

Often it’s not obvious which object doesn’t get disposed and causes this behaviour. Usually it takes me several days to find the culprit and fix the bug. Over the years I developed some strategies that get refined over time. When I came across this situation again last week I decided to create a tracker class that keeps track of the created and disposed objects together with a counter that identifies the creation call. This made it easier to add a method call to the constructor and the Dispose() method but it still required quite a bit of repetitive work to temporarily add those calls to the c’tor and Dispose methods.

On the weekend I stumbled upon the nuget package Fody; this helped an idea to materialize that I had for a few days. As a consequence I created a fody addin, Undisposed.Fody, that injects calls to my tracker class into the constructor and dispose methods of all types in the current assembly. The fody addin gets run during the build of the current project. I also created a standalone application that allows to hack an existing assembly.

The modified assembly outputs a line on the console if an object gets created and when it gets disposed, and it dumps all undisposed objects. Hopefully this will give some hints which object creation calls to inspect.

The source code is available on github, and there is also a nuget package.

Remote Debugging with MonoDevelop

2013/12/04

This morning I tried to debug some Mono code in a Ubuntu 13.10 Saucy virtual machine that doesn’t have all the developer tools installed. Miguel de Icaza recently blogged about remote debugging, but it took a bit of fiddling to get it working. Here are my findings:

In the VM start your application with

mono --debug --debugger-agent="address=192.177.88.11:10000,transport=dt_socket,server=y" \
    /full/path/to/mono-application.exe

The IP address is the address of the VM, transport is a required argument, dt_socket seems to be the only allowed option. It is important to specify the full path to your managed application otherwise you’ll get an error that the application can’t be found.

Then on your developer machine set the environment variable MONODEVELOP_SDB_TEST and start MonoDevelop:

export MONODEVELOP_SDB_TEST=1
monodevelop-4.0

This adds a new menu item that allows to start a remote debugging session, under Run -> Run With -> Custom Command Mono Soft Debugger. This opens a dialog window; enter the IP address of your VM (192.177.88.11) and the port (10000) and start the session with the Connect button. This starts the application in the VM. Debugging works the same as if you would start the app locally. Great!

Fingerprint reader on Ubuntu 12.04

2013/01/31

Yesterday I finally upgraded my Dell D830 laptop to Ubuntu 12.04 Precise. Everything went smoothly – great!

Today I decided to give the fingerprint sensor another try – after reinstalling my machine last year I hadn’t bothered to get the fingerprint reader to work again. Read the rest of this entry »

Finding the language for a xkb keyboard

2011/07/21

During the last days I was working on keyboarding issues on Linux. In our app we want to display the (xkb) keyboards that the user has installed and that are visible in the gnome panel. Displaying them is relatively easy, but then I also needed the language that is associated with the keyboard. Read the rest of this entry »

Cross-Platform Development and Data Type Sizes

2011/06/10

One of the problems when developing cross-platform apps is the question how long the intrinsic data types are on the different platforms. A while ago I created a table with the sizes of the different data types on 32- and 64-bit Windows and Linux, both for C++ and C#/.NET. Read the rest of this entry »

Lost Menu in Monodevelop in Unity

2011/06/07

Recently I got a new desktop computer on which I installed Ubuntu 11.04 Natty with the Unity UI. Yesterday I compiled Monodevelop 2.6 beta 3 (using the scripts described here) which worked fine – only when I run monodevelop the menu can’t be found anywhere: there is no menu in the monodevelop window nor in the global menu bar. Since it’s pretty hard to do any work without a visible menu, I decided to try to get this fixed. Read the rest of this entry »

Location of special folders on Linux

2011/04/14

One thing that always confuses me is how the special folders of Environment.SpecialFolder translate into real directories. Some are really obvious, especially on Windows, but on Mono on Linux it’s not so obvious. So I wrote a little app that tells where those folders are. Read the rest of this entry »

Applications menu disappeared

2010/01/19

This morning when I turned on my laptop I noticed that the Applications menu in Ubuntu 9.10 had disappeared – well, not completely, it was still shown in the panel, but when clicking on it it only showed a tiny little rectangle instead of popping up the application list. Read the rest of this entry »

Firefox suddenly doesn’t resolve names any more

2009/08/07

After returning from vacation I was confronted with a really strange problem on my laptop. Firefox wasn’t any more able to load pages from certain domains. After a reboot it worked, but sooner or later it stopped working. Read the rest of this entry »


Follow

Get every new post delivered to your Inbox.