Sign in to follow this  
Endar

testing framework

Recommended Posts

Endar    668
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 this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
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 this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
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 this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this