I want to test a couple of functions in my source code with unit tests. Now If I run my test I don't get any test results.
Here is a simple Code Snippet what I try to do:
#include <iostream>
using namespace std;
namespace UnitTest
{
[TestClass]
public ref class UnitTestBlueSmart
int main(){
public:
[TestMethod()]
hello();
}
}
void hello(){
cout<<"Hello World!";
}
Does anyone know why this is not working?
The problem is that you're not performing the unit tests correctly. You should rely on not getting Asserts, not on printing to the console.
The concept is to check methods and make sure they return the correct value.
See the following links for more details:
http://whinery.wordpress.com/2012/07/21/native-c-unit-testing-with-ms-test/
http://msdn.microsoft.com/en-us/library/ms182532.aspx
Specifically using your code, an example of a correct unit test would be:
and creating a TestMethod which will Assert if the value is incorrect. For instance: