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?
Unit Testing tools are the testing tools such as JUnit, TestNG, NUnit, PHPUnit, etc., which are used to perform unit testing on a specific module of code developed by the application developer.
Unit testing tools are used by the developers to test the source code of the application or to achieve the source code of the application.
NUnit is an open-source unit testing framework for the . NET Framework and Mono. It serves the same purpose as JUnit does in the Java world, and is one of many programs in the xUnit family.
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));
}
};
}
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With