I am going to start implementing some unit tests for a codebase that is a mix of managed and unmanaged C++. Can NUnit hack it with unmanaged code? Is there a better alternative?
views:
291answers:
2
+3
A:
It's possible to use NUnit to test unmanaged code, example:
// Tests.h
#pragma once
#include <cmath>
using namespace System;
using namespace NUnit::Framework;
namespace Tests {
[TestFixture]
public ref class UnitTest
{
public:
UnitTest(void) {}
[Test]
void TestCos()
{
Assert::AreEqual(1, cos(0.0));
}
};
}
Dmitriy Matveev
2009-01-14 16:42:40
+1
A:
NUnit will work fine with unmanaged code as long as you write the unit tests in managed C++. The outside wrapper will be NUnit friendly and can access the unmanaged parts.
plinth
2009-01-14 17:11:08