Connecting MBUnit and NUnit to TestLink
Thursday, 02 April 2009 12:36

This article describes how to have results from unit tests in MBUnit and NUNit recorded in TestLink. This work is based upon the C# library that allows remote procedure calls to TestLink.

All code can be found under http://code.google.com/p/gallio-testlink-adapter/

MBUnit and NUnit are unit test frameworks for the C# language. Using a C# attribute it is possible to decorate these tests with information of where the test results need to be stored.

Principle of Operation

The TestFixture is decorated with a TestLinkFixture attribute. This attribute contains all necessary information of where the test results are to be recorded:

  • The url of the TestLink server
  • The API Key
  • The author name (in case test cases need to be created)
  • The Test Project Name
  • The Test Plan Name
  • The Test Suite Name

The individual testcase names are derived from the test method names in the test fixture.

The test runner frameworks (console runner in Gallio and either the console runner or the GUI runner in NUnit) load an extension called the TestLink Adapter. When they run the tests they will make calls to the extension for each test. The extension then retrieves the TestLinkFixture attribute for each test fixture and calls the TestLink server to record the test case result.

If the test case does not yet exist, the TestLink Adapter will create a test case in the test suite and assign it to the test plan before recording the result.

Example

The following is a typical example from MBUnit (NUnit looks the same with the exception of different using statements)

using MbUnit.Framework;
using TlGallioAddOn;

namespace gallioAddOnSampleTests
{
   
[TestFixture]
   
[TestLinkFixture(
       
Url = "http://localhost/testlink/lib/api/xmlrpc.php",
       
ProjectName = "TestLinkApi",
       
UserId = "admin",
       
TestPlan = "Automatic Testing",
       
TestSuite = "gallioAddOnSampleTests",
       
DevKey = "ae28ffa45712a041fa0b31dfacb75e29")]
   
public class SampleFixture
   
{
       
[Test]
       
public void Test2Succeed()
       
{
           
Assert.IsTrue(true);
       
}
   
}
}

The code above defines a testfixture by the name of SampleFixture and has exactly one test method called Test2Succeed. When run the testlink adapter will record the result in a testcase called Test2Succeed.

Downloading and Installation

Download the binaries from google code. The web site has  pages that will run through the installation and use for both NUnit and MBUnit.

http://code.google.com/p/gallio-testlink-adapter/

MBUnit (Gallio): http://gallio-testlink-adapter.googlecode.com/files/TlGallioAddOnBinaries%20V1.1.zip

NUnit: http://gallio-testlink-adapter.googlecode.com/files/Nunit%20TestLink%20Exporter%20Binaries.zip

The C# Testlink API

This work is based upon the C# TestLink API. This is a C# library giving access to the XMLRPC library of TestLink. If you want to do other automation work with Testlink you can just download the sources for that one.

If you have Questions or want changes

are welcome to contribute. Drop me a line on Google Code http://code.google.com/p/gallio-testlink-adapter/

Last Updated on Friday, 03 April 2009 12:59