### 프로그래머 지원 블로그 ### http://iwoohaha.tistory.com 

프로그래머는 이렇게 산다
by 우하하 이글루스 피플



이글루 파인더
활용~!!
최근 등록된 덧글
옴니아는 터치가 구리죠...
by 450 at 11/04
우리집도 살때부터 찌릿..
by 삼성냉장고 at 11/02
찌릿찌릿 전기 통하는걸..
by 콘스탄티노 at 10/30
오즈옴니아 땡기는데.. ..
by 오좀니아 at 10/30
우리집도...찌릿하던데..
by 김혜은 at 10/30
T*OMNIA만 2이고, SH..
by 파미 at 10/29
아이폰나와여 되는데말..
by 450 at 10/29
카테고리
생활의흔적
프로그래밍
컴퓨팅환경
요즘읽는책
블로그활용
공개자료실
아갖고싶다
디카작품전
즐겨서찾기
해야할일들
해보고싶은
작성중인글(비공개)
우하하실록
가보고싶은
결혼이야기
웃어보자구
모바일생활
공연이야기
마이쭈니어
음악이야기
부자만들기
소프트웨어
개발기록지
최근 등록된 트랙백
chrome for mac
by 착각속의 (아가)고양이 ..
이통사가 스마트폰 수입..
by 아라의 글로벌 마인드 칼..
아이폰, 스마트폰 등이..
by 아라의 글로벌 마인드 칼..
국회의원의 점심식사는?
by 미래를 만드는 정치인 ..
태그
앱스토어 iPhone 프라임 디폴트속성 네비바 컨버전스기기 단어학습 아이팟OS버그인가 체크카드혜택 새로운기능 한영사전 방통위는 두산동아 5개국어 보카 iPodTouch KB체크카드 기억력테스트 정신좀차려라 아이팟터치 제발부탁이다 꺼짐은어떨까 voca 영한사전 깜빡이 프로그래밍언어 프로모션 M8200 아이폰
이전블로그
2009년 11월
2009년 10월
2009년 09월
2009년 08월
more...
라이프로그
rss

skin by 봉팔
CPPUnit 을 사용하기 위한 단계별 작업
CPPUnit은 이미 시스템에 설치되어 있다고 가정한다.
설치하는 방법

App 클래스에 대해서 할 작업 ===========================

1. 테스트 프로젝트의 App 클래스(CWinApp로부터 파생되는 클래스) 구현 파일에 다음 두 개의 인클루드문을 추가한다.

#include <msvc6/testrunner/testrunner.h>
#include <cppunit/extensions/testfactoryregistry.h>


2. App 클래스 InitInstance 함수에 TestRunner를 동작시키는 다음 코드를 추가한다.

  TestRunner runner;
  runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
  runner.run();


테스트 메소드를 작성할 테스트 클래스 작성 ===========================

1. 프로젝트에 테스트 메소드를 작성할 클래스를 추가한다.
이 클래스는 반드시 CppUnit::TestCase 으로부터 파생되어야 한다.

헤더파일(Test_PrinterInfo.h)
// 실제로 구현하게 될 CPrinterInfo 클래스를 테스트할 목적으로 만든 테스트 클래스
//////////////////////////////////////////////////////////////////////

#ifndef __TEST_PRINTERINFO_H__
#define __TEST_PRINTERINFO_H__

#include <cppunit/TestCase.h>  
#include <cppunit/extensions/HelperMacros.h> 


class CTest_PrinterInfo : public CppUnit::TestCase  
{
public:
  CTest_PrinterInfo();
  virtual ~CTest_PrinterInfo();

};

#endif // #ifndef __TEST_PRINTERINFO_H__

구현파일(Test_PrinterInfo.cpp)
// Test_PrinterInfo.cpp: implementation of the CTest_PrinterInfo class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "Test_PrinterInfo.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CTest_PrinterInfo::CTest_PrinterInfo()
{

}

CTest_PrinterInfo::~CTest_PrinterInfo()
{

}

2. 이 클래스가 CPPUnit을 사용할 수 있게 하기 위한 매크로를 추가한다.
헤더파일
// 실제로 구현하게 될 CPrinterInfo 클래스를 테스트할 목적으로 만든 테스트 클래스
//////////////////////////////////////////////////////////////////////

#ifndef __TEST_PRINTERINFO_H__
#define __TEST_PRINTERINFO_H__

#include <cppunit/TestCase.h>  
#include <cppunit/extensions/HelperMacros.h> 

class CTest_PrinterInfo : public CppUnit::TestCase  
{
    // TestSuite 
    CPPUNIT_TEST_SUITE( CTest_PrinterInfo );
    
    // TestCase 의 등록. 
    
    CPPUNIT_TEST_SUITE_END(); 


public:
  CTest_PrinterInfo();
  virtual ~CTest_PrinterInfo();

};

#endif // #ifndef __TEST_PRINTERINFO_H__

구현파일
// Test_PrinterInfo.cpp: implementation of the CTest_PrinterInfo class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "Test_PrinterInfo.h"

CPPUNIT_TEST_SUITE_REGISTRATION( CTest_PrinterInfo ); // 등록!!!

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CTest_PrinterInfo::CTest_PrinterInfo()
{

}

CTest_PrinterInfo::~CTest_PrinterInfo()
{

}

3. 테스트 메소드를 추가하고 CPPUnit 매크로를 추가하여 TestCase로서 등록한다.
헤더파일
// 실제로 구현하게 될 CPrinterInfo 클래스를 테스트할 목적으로 만든 테스트 클래스
//////////////////////////////////////////////////////////////////////

#ifndef __TEST_PRINTERINFO_H__
#define __TEST_PRINTERINFO_H__

#include <cppunit/TestCase.h>  
#include <cppunit/extensions/HelperMacros.h> 

class CTest_PrinterInfo : public CppUnit::TestCase  
{
    // TestSuite 
    CPPUNIT_TEST_SUITE( CTest_PrinterInfo );
    
    // TestCase 의 등록. 
    CPPUNIT_TEST( Test_GetPrinterInfo );
    
    CPPUNIT_TEST_SUITE_END(); 

public:
  CTest_PrinterInfo();
  virtual ~CTest_PrinterInfo();

protected:
    void Test_GetPrinterInfo();

};

#endif // #ifndef __TEST_PRINTERINFO_H__

구현파일
// Test_PrinterInfo.cpp: implementation of the CTest_PrinterInfo class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "Test_PrinterInfo.h"

CPPUNIT_TEST_SUITE_REGISTRATION( CTest_PrinterInfo ); // 등록!!!

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CTest_PrinterInfo::CTest_PrinterInfo()
{

}

CTest_PrinterInfo::~CTest_PrinterInfo()
{

}

void CTest_PrinterInfo::Test_GetPrinterInfo()
{

}

4. 프로젝트 셋팅에 두 개의 lib 파일에 대한 링크를 걸어준다.
cppunitd.lib testrunnerd.lib
릴리즈 버전일 때는
cppunit.lib testrunner.lib

5. 프로젝트 셋팅에서 C/C++, C++ Language 항목의 Enable Run_time Type Information (RTTI)항목을 활성화시킨다.

6. 실행파일이 존재하는 디렉토리에 testrunnerd.dll 또는 testrunner.dll 이 있어야 동작을 한다는 사실...
이 블로그를 구독하시려면 이 버튼을 눌러주세요 ===>


by 우하하 | 2004/05/18 15:36 | 프로그래밍 | 트랙백(5) | 덧글(1) | ▲ Top
트랙백 주소 : http://woohaha.egloos.com/tb/519341
☞ 내 이글루에 이 글과 관련된 글 쓰기 (트랙백 보내기) [도움말]
Tracked from HTTP 404 - 파.. at 2004/05/18 16:14

제목 : CPPUnit 을 사용하기 위한 단계별 작업
CPPUnit 을 사용하기 위한 단계별 작업...more

Tracked from 우하하!!~ 웃으면서 .. at 2004/06/27 02:46

제목 : CPPUnit 프로젝트 샘플
CPPUnit 을 사용하기 위한 단계별 작업 제가 올린 위 포스트에서 설명한 대로(클래스 이름은 좀 다릅니다만...) 하나의 예제 프로젝트를 만들어봤습니다. 이거 하나 맹글어놓고 여기 저기서 사용할 클래스들을 테스트하는 용도로 사용하면 무척 편리하더군요... 다운로드는 이곳에서... ...more

Tracked from swallow의 프로그.. at 2004/06/28 11:50

제목 : CPPUnit 을 사용하기 위한 단계별 작업
CPPUnit은 이미 시스템에 설치되어 있다고 가정한다. App 클래스에 대해서 할 작업 =========================== 1. 테스트 프로젝트의 App 클래스(CWinApp로부터 파생되는 클래스) 구현 파일에 다음 두 개의 인클루드문을 추가한다. #include #include 2. App 클래스 InitInstance 함수에 TestRunner를 동작시키는 다음 코드를 추가한다. TestRunner runner; runner.addTest(CppUnit::TestFa......more

Tracked from 오늘도 삽질중 at 2007/01/11 13:27

제목 : cppunit을 사용하기 위한 단계별 작업
CPPUnit 을 사용하기 위한 단계별 작업 ...more

Tracked from OOPS! at 2007/09/19 18:06

제목 : CppUnit을 사용한 Unit 테스트 코드 작성법
2006-11-16-CppUnit 코드 작성법.pdf예전에 만들었던 PDF 파일을 첨부합니다. 참고하시길 :-)...more

Commented by 감사감사 at 2007/05/06 01:36
감사합니다. 많이 보고 배웁니다.

:         :

:

비공개 덧글



◀ 이전 페이지 다음 페이지 ▶