Skip to content

Commit

Permalink
Merge pull request #1654 from kazasaku/feature/update_test_document
Browse files Browse the repository at this point in the history
単体テストに関するドキュメント( unittest.md )を tests ディレクトリに移動
  • Loading branch information
Kohki Akikaze committed May 3, 2021
2 parents b68f544 + 611cd71 commit 00bc361
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 83 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ https://ci.appveyor.com/project/sakuraeditor/sakura/history

### 単体テスト

[単体テスト](unittest.md) を参照
[こちら](tests/unittest.md) を参照してください。

### デバッグ方法

Expand Down
4 changes: 2 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ trigger:
- tools/find-tools.md
- tools/macro/macro.md
- tools/zip/readme.md
- unittest.md
- tests/unittest.md
- vcx-props/project-PlatformToolset.md

###############################################################################################################################
Expand Down Expand Up @@ -77,7 +77,7 @@ pr:
- tools/find-tools.md
- tools/macro/macro.md
- tools/zip/readme.md
- unittest.md
- tests/unittest.md
- vcx-props/project-PlatformToolset.md

###############################################################################################################################
Expand Down
86 changes: 86 additions & 0 deletions tests/unittest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# 単体テスト

<!-- TOC -->

- [単体テスト](#単体テスト)
- [GoogleTest](#googletest)
- [CMake](#cmake)
- [単体テストのディレクトリ構造](#単体テストのディレクトリ構造)
- [単体テスト関連のバッチファイル](#単体テスト関連のバッチファイル)
- [一覧](#一覧)
- [呼び出し構造](#呼び出し構造)
- [使用するバッチファイルの引数](#使用するバッチファイルの引数)
- [インクルードディレクトリ](#インクルードディレクトリ)

<!-- /TOC -->

## GoogleTest

単体テストフレームワークとしてオープンソースでいくつか公開されていますが、
Google が開発している [GoogleTest](https://github.com/google/googletest) を使用します。

[GoogleTest](https://github.com/google/googletest) は GitHub でソースコードが公開されているので
git submodule の機能を使用してソースコードを参照してテストと同時にビルドします。

## CMake

GoogleTest はビルドシステムに [CMake](https://cmake.org/) を使用します。
CMake は CMakeLists.txt というテキストファイルにビルド設定を記載して
CMake を実行することにより、各プラットフォームに固有のネイティブの
ビルドシステム用のファイルを生成してビルドします。

GoogleTest を使用して作成する単体テストも CMake でビルド設定を行います。

CMake は Visual Studio 用のプロジェクト生成に対応しているため
Visual Studio 用のプロジェクトを生成してビルドすれば
GUI でステップ実行することができます。

## 単体テストのディレクトリ構造

- tests
- compiletests (コンパイルテスト用のファイルを置くディレクトリ)
- googletest (googletest 用のフォルダ。git submodule)
- unittests (単体テストの実体を置く。中の構成は要検討)
- build (ビルド時に生成されるフォルダ。git には登録しない)
- Win32 (Win32 用のプロジェクトを格納するフォルダ)
- x64 (x64 用のプロジェクトを格納するフォルダ)

## 単体テスト関連のバッチファイル

### 一覧

| バッチファイル | 説明 |
----|----
|[tests\build-and-test.bat](build-and-test.bat) | ビルドと単体テストを順に行う |
|[tests\create-project.bat](create-project.bat) | 単体テスト用のプロジェクトファイルを作成する |
|[tests\build-project.bat](build-project.bat) | 単体テスト用のプロジェクトをビルドする |
|[tests\run-tests.bat](run-tests.bat) | 単体テストを実行する |

### 呼び出し構造

- [tests\build-and-test.bat](build-and-test.bat)
- [tests\create-project.bat](create-project.bat)
- [build-gnu.bat](../build-gnu.bat) : Makefile をビルドする (platform が MinGW の場合)
- [build-sln.bat](../build-sln.bat) : ソリューションをビルドする (platform が Win32 または x64 の場合)
- git.exe
- cmake.exe
- [tests\build-project.bat](build-project.bat)
- git.exe
- cmake.exe
- [tests\run-tests.bat](run-tests.bat)
- tests\tests*.exe : 単体テストを実行する
- [tests\test_result_filter_tell_AppVeyor.bat](test_result_filter_tell_AppVeyor.bat) : AppVeyor のテストタブにテスト結果を出力する

### 使用するバッチファイルの引数

| バッチファイル | 第一引数 | 第二引数 |
----|----|----
|[tests\build-and-test.bat](build-and-test.bat) | platform ("Win32" または "x64" または "MinGW") | configuration ("Debug" または "Release") |
|[tests\create-project.bat](create-project.bat) | platform ("Win32" または "x64") | configuration ("Debug" または "Release") |
|[tests\build-project.bat](build-project.bat) | platform ("Win32" または "x64") | configuration ("Debug" または "Release") |
|[tests\run-tests.bat](run-tests.bat) | platform ("Win32" または "x64") | configuration ("Debug" または "Release") |

## インクルードディレクトリ

単体テスト用の [CMakeLists.txt](unittests/CMakeLists.txt)[サクラエディタ用のディレクトリ](../sakura_core)
インクルードディレクトリに指定しているので、そこからの相対パスを指定すれば、サクラエディタのヘッダをインクルードできます。
80 changes: 0 additions & 80 deletions unittest.md

This file was deleted.

0 comments on commit 00bc361

Please sign in to comment.