Catch2 테스트 만들기
Catch2 테스트를 빌드하고 실행하려면 Catch2 라이브러리와 헤더를 설치하거나 Catch2 리포지토리에 있는 단일 include 헤더 파일을 사용할 수 있습니다.
컴파일러와 빌드 시스템이 자동으로 Catch2 헤더를 찾을 수 있는 경우 테스트를 만들 때 include 디렉터리를 지정할 필요가 없습니다.
기본 Catch2 테스트를 생성하려면 다음과 같이 하세요:
- File > New Project > Test Project 로 이동합니다.
- Catch2 Test Project > Choose 을 선택하여 Catch2 테스트용 상용구 코드가 포함된 프로젝트를 만듭니다.
- Project and Test Information 대화 상자에서 프로젝트 및 테스트에 대한 설정을 지정합니다:

- Test framework 에서 Catch2 v3 (shared libraries) 을 선택하여 Catch2에 대해 링크하거나(버전 3에 권장), Catch2 v2 (header only) 을 선택하여 단일 헤더 포함을 사용합니다(버전 2에 권장).
- Test case name 에서 테스트 케이스 파일의 이름을 지정합니다.
- Catch2 install directory (optional) 에 Catch2 헤더 파일이 있는 디렉터리 경로를 입력할 수 있습니다.
- 자체 정의된 메인 함수를 사용하려면 Use own main 을 선택합니다.
- Use Qt libraries 을 선택하여 Qt 기능을 사용하도록 프로젝트를 설정합니다.
- Build system 에서 프로젝트 빌드에 사용할 빌드 시스템을 선택합니다: CMake, qmake 또는 Qbs 중 하나를 선택합니다.
Qt Creator 프로젝트 디렉토리에 테스트를 생성합니다.
Catch2 테스트 생성에 대한 자세한 내용은 Catch2를 참조하십시오.
참고: 테스트를 검색하는 동안 파서는 일반적인 Catch2 헤더(catch2.hpp, catch_all.hpp 등) 중 하나를 직간접적으로 포함하는 파일만 고려합니다. 현재 빌드되지 않는 파일은 무시됩니다.
Copyright © The Qt Company Ltd. and other contributors. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.