How to use "UnitTest" to test C++ code [modified]
-
"UnitTest" is on the VC's main menu,I want to use itto test my C++ code, but I am not familiar with its mechanism. I wrote a little code expecting to learn how it works.But seems not work. here's my code
class myClass
{
private:
int m_i ;
public:
myClass( int i ):m_i(i){ }
BOOL EQ( int i )
{
if( m_i == i )
return TRUE ;
else
return FALSE ;
}
} ;int main()
{
myClass mc( 10 ) ;
}I click "new UnitTest", go through a few steps,when trying click the checkbox besides my project name, there's always a msg reporting unsuccessful "Unknown virtual address 0". Waiting for help...
modified on Thursday, July 21, 2011 5:09 AM
-
"UnitTest" is on the VC's main menu,I want to use itto test my C++ code, but I am not familiar with its mechanism. I wrote a little code expecting to learn how it works.But seems not work. here's my code
class myClass
{
private:
int m_i ;
public:
myClass( int i ):m_i(i){ }
BOOL EQ( int i )
{
if( m_i == i )
return TRUE ;
else
return FALSE ;
}
} ;int main()
{
myClass mc( 10 ) ;
}I click "new UnitTest", go through a few steps,when trying click the checkbox besides my project name, there's always a msg reporting unsuccessful "Unknown virtual address 0". Waiting for help...
modified on Thursday, July 21, 2011 5:09 AM
I haven't used the tool myself, but isn't there a startup guide to make us understanding the procedure to be followed. Also, you can refer the articles on MSDN and I sure you will find more than one that will guide you further.
You talk about Being HUMAN. I have it in my name AnsHUMAN
-
I haven't used the tool myself, but isn't there a startup guide to make us understanding the procedure to be followed. Also, you can refer the articles on MSDN and I sure you will find more than one that will guide you further.
You talk about Being HUMAN. I have it in my name AnsHUMAN
Certainly good advice, but I have to say it may not be easy to find useful material: I've faced almost the same problem, and my searches turned up tons of Tools for Unit-Testing or Tutorials for using such tools, but virtually nothing about how to set up a unit test in the first place! :( Maybe an explicit search at specific sites such as MSDN or various technical forums might help - I haven't tried that yet.
-
Certainly good advice, but I have to say it may not be easy to find useful material: I've faced almost the same problem, and my searches turned up tons of Tools for Unit-Testing or Tutorials for using such tools, but virtually nothing about how to set up a unit test in the first place! :( Maybe an explicit search at specific sites such as MSDN or various technical forums might help - I haven't tried that yet.
Yeah, I searched lot, still haven't found too much helpful materials.I think I should give up using it since it related tightly with netFramework.Someone says C++ test is one of the best UnitTest tool, I'll have a try.
-
Yeah, I searched lot, still haven't found too much helpful materials.I think I should give up using it since it related tightly with netFramework.Someone says C++ test is one of the best UnitTest tool, I'll have a try.
Indeed. I've been spending the last hour to find something more useful, and have all but given up. At the moment I'm digesting the entries on Unit testing that I've found on Wikipedia, just to be make sure I fully understand the concepts. Maybe that's a good place for you to look too? Unit Testing - Wikipedia
-
Indeed. I've been spending the last hour to find something more useful, and have all but given up. At the moment I'm digesting the entries on Unit testing that I've found on Wikipedia, just to be make sure I fully understand the concepts. Maybe that's a good place for you to look too? Unit Testing - Wikipedia
Thanks, Stefan. I'll take a look.I love Wiki too. It was the place that taught me how to do the matrix multiplication.Hoho :)
-
"UnitTest" is on the VC's main menu,I want to use itto test my C++ code, but I am not familiar with its mechanism. I wrote a little code expecting to learn how it works.But seems not work. here's my code
class myClass
{
private:
int m_i ;
public:
myClass( int i ):m_i(i){ }
BOOL EQ( int i )
{
if( m_i == i )
return TRUE ;
else
return FALSE ;
}
} ;int main()
{
myClass mc( 10 ) ;
}I click "new UnitTest", go through a few steps,when trying click the checkbox besides my project name, there's always a msg reporting unsuccessful "Unknown virtual address 0". Waiting for help...
modified on Thursday, July 21, 2011 5:09 AM
This might help: Unit-Testing Native C++ with Visual Studio[^] By using the Unit Testing framework in Visual Studio, then you should automatically get the ability to see code coverage (Though it requires one of the expensive Visual Studio Editions)