Click here to Skip to main content
15,897,518 members
Articles / Mobile Apps

Unit Testing Framework for eVC++ Applications

Rate me:
Please Sign up or sign in to vote.
4.63/5 (13 votes)
17 Oct 2004CPOL6 min read 85.4K   246   28  
A unit testing framework for eVC++ applications, and its usage.
/******************************************************************************
 * File Name:		TestCaseInfo.cpp
 * Description:		This file contains the definitions of all the functions of 
 *					CTestCaseInfo class.
 * Date:			20/7/2004
 * Author:			AbdulMunaf Chhatra
 * E-Mail:			a.chhatra@popnet.co.in
 *
 * Warning:
 * This code is provided as is without any guarantee or warranty, implicit or 
 * explicit. If this code damages your system then the author is not 
 * responsible for it. This code is free to use with the permission of author. 
 * If you want to use this code then please send me an email at 
 * a.chhatra@popnet.co.in for permission, I will gladly give the permission. 
 * If you make any changes in this code, then feel free to add your name here, 
 * but this notice should appear in this code.
 ******************************************************************************
 * ------------------------------
 * Version History
 * ------------------------------
 * Version	:  1.0
 * Author	:  AbdulMunaf Chhatra
 * Date    	:  20/7/2004
 * Comment 	:  Initial release
 * ------------------------------
 *****************************************************************************/
 
#include "stdafx.h"
#include "TestCaseInfo.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

/******************************************************************************
 * Description:		Default constructor.
 * 
 * Parameters:
 * 
 * 
 * Return Value:	N/A
 *****************************************************************************/
CTestCaseInfo::CTestCaseInfo()
{
	m_pTestCase 	= NULL;
	m_bException	= FALSE;
	m_strTestName.Empty();
}

/******************************************************************************
 * Description:		Distructor.
 * 
 * Parameters:
 * 
 * 
 * Return Value:	N/A
 *****************************************************************************/
CTestCaseInfo::~CTestCaseInfo()
{
	m_pTestCase 	= NULL;
	m_strTestName.Empty();
}

/******************************************************************************
 * Description:		Sets the m_pTestCase member to parameter passed to it.
 * 
 * Parameters:
 * void (CTestSuite::*a_pTestCase)(void):
 *					Pointer to function to be set to m_pTestCase member.
 * 
 * Return Value:	none.
 *****************************************************************************/
void CTestCaseInfo::SetTestCase(void (CTestSuite::*pTestCase)(void))
{
	m_pTestCase = pTestCase;
}

/******************************************************************************
 * Description:		Returns the m_pTestCase member. This is pointer to function
 *					of CTestSuite class member function.
 * 
 * Parameters:
 * 
 * 
 * Return Value:	none.
 *****************************************************************************/
void CTestCaseInfo::GetTestCase(void (CTestSuite::*pTestCase)(void))
{
	pTestCase = m_pTestCase;
}

/******************************************************************************
 * Description:		Sets the test case name.
 * 
 * Parameters:
 * strTestName:		Name to be set.
 * 
 * Return Value:	none.
 *****************************************************************************/
void CTestCaseInfo::SetTestName(CString strTestName)
{
	m_strTestName = strTestName;
}

/******************************************************************************
 * Description:		Retruns the name of test case.
 * 
 * Parameters:
 * 
 * 
 * Return Value:	Name of test case.
 *****************************************************************************/
CString CTestCaseInfo::GetTestName()
{
	return m_strTestName;
}

/******************************************************************************
 * Description:		Sets the exception flag.
 * 
 * Parameters:
 * bException:		Flag to be set.
 * 
 * Return Value:	none.
 *****************************************************************************/
void CTestCaseInfo::SetExceptionFlag(BOOL bException)
{
	m_bException = bException;
}

/******************************************************************************
 * Description:		Returns the exception flag.
 * 
 * Parameters:
 * 
 * 
 * Return Value:	Exception flag.
 *****************************************************************************/
BOOL CTestCaseInfo::GetExceptionFlag()
{
	return m_bException;
}

/******************************************************************************
 * Description:		Sets the exception name.
 * 
 * Parameters:
 * strException:	Name of execption to be set.
 * 
 * Return Value:	none.
 *****************************************************************************/
void CTestCaseInfo::SetExceptionName(CString strException)
{
	m_strException = strException;
}

/******************************************************************************
 * Description:		Retruns the name of exception.
 * 
 * Parameters:
 * 
 * 
 * Return Value:	Name of exception.
 *****************************************************************************/
CString CTestCaseInfo::GetExceptionName()
{
	return m_strException;
}

/******************************************************************************
 * Description:		Compares the name of test with the parameter passed to it.
 * 
 * Parameters:
 * strName:			Name to be matched with the test case name.
 * 
 * Return Value:	True if name matches else False.
 *****************************************************************************/
BOOL CTestCaseInfo::CompareTestName(CString strName)
{
	return (m_strTestName == strName);
}

/******************************************************************************
 * Description:		Overloaded '=' operator.
 * 
 * Parameters:
 * objSource:		Source object which is to be copied to this object.
 * 
 * Return Value:	none.
 *****************************************************************************/
void CTestCaseInfo :: operator =(CTestCaseInfo objSource)
{
    m_bException    = objSource.m_bException;
    m_strException  = objSource.m_strException;
    m_strTestName   = objSource.m_strTestName;
    m_pTestCase     = objSource.m_pTestCase;

    return;
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
India India
A person who like to know about new things, peolple and make frineds. I strarted programming in 2000 with fortran but my first love in programming is C++. Also programmed in VB, MFC and for Windows CE.

Graduated in Physics and done masteres in Computer application. Physics and astronomy are my area of intrest. Karate is also one of my hobbies, BTW I am a Black Belt in Karate.

Comments and Discussions