# testing framework

This topic is 4055 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Since re-writing my engine is going to be a big deal, I'd like to write a framework for testing and I'm not really sure how to go about it. I've thought of a simple class:
template<class T>
class TestCase
{
private:

std::string m_testDescription;		///< A string describing the test

public:

/**
* Constructor
* \param s The description that this test object will perform
*/
TestCase(const std::string& s)
:	m_testDescription(s)
{	}

/**
* Perform the test
* \param obj The object to perform the test on
* \return Whether the test passed or not
*/
virtual bool test( T& obj ) const = 0;

};


Something like that so I can just create a small new class, that derives from 'TestCase', for each test. I'll have to define the constructor and the 'test' function for each different test that I do. I'll probably need something more complicated in the future, but I was just wondering how this was for a start? Or, if you've got any ideas for the future, definately chime in.

##### Share on other sites
These are commonly known as "mock up" objects, in general however you may want to simply do a forum search for "unit testing", likewise checking out the corresponding wikipedia matches for "unit test*" and "test driven development" might also be worthwhile thing to do.

HTH

##### Share on other sites
You may consider using UnitTest++ (http://unittest-cpp.sourceforge.net/). I haven't used it personally yet, but I know some people that swear on it.

##### Share on other sites

This topic is 4055 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.