LoginSignup
9
10

More than 5 years have passed since last update.

テスト自動化ツール Gaugeの紹介

Last updated at Posted at 2016-08-12

ThoughtWorks社が開発しているテスト自動化ツール「Gauge」の紹介です。
http://getgauge.io/

概要

  • golangで書かれたオープンソースのテスト自動化ツール
  • Markdownでテスト仕様を記述する。様々なフォーマットのドキュメントを生成
  • データ駆動実行。テスト仕様の可読性を保ちながら、大きなデータセットを容易にテスト可能

2016年8月現在まだベータ版とのことですが、気になるので触ってみようと思います。

使い方

公式のGET STARTEDに沿って進めてみます
http://getgauge.io/get-started/index.html

Gaugeのインストール

MacなのでHomebrewからインストールします。
WindowsやLinuxではパッケージが用意されているのでそちらを利用して下さい。

$ brew update
$ brew install gauge

プラグインの導入

gauge --install プラグイン名でプラグインをインストール出来ます。
テストを記述する開発言語に合わせたプラグインを導入してください。

$ gauge --install java
Gathering metadata for java

Plugin java 0.5.0 is already installed.

私の場合、javaプラグインは導入済みだったようです。
ついでにhtml-reportプラグインを導入しておきます。

$ gauge --install html-report
Gathering metadata for html-report

Downloading html-report-2.1.1-darwin.x86_64.zip
....
Installing plugin html-report 2.1.1
Successfully installed plugin 'html-report'.

利用可能なプラグインの一覧はGAUGE PLUGINSを参照。

プロジェクトの作成

空のディレクトリを作った後、gaugeコマンドでプロジェクトの雛形を作成します。

$ mkdir hello_gauge
$ cd hello_gauge
$ gauge --init java
Downloading java.zip
...
Copying Gauge template java to current directory ...
Successfully initialized the project. Run specifications with "gauge specs/".

雛形は自動的にダウンロードされるようです。展開された雛形は以下のような構造になっています。

$ tree
.
├── env
│   └── default
│       ├── default.properties
│       └── java.properties
├── libs
├── manifest.json
├── specs
│   └── example.spec
└── src
    └── test
        └── java
            └── StepImplementation.java

7 directories, 5 files

example.specがテスト仕様、StepImplementation.javaがテスト実装でしょうか。

テストの実行

テストを実行してみます。
specsディレクトリに配置されているexample.specの通りにテストが実行されるようです。

$ gauge specs
# Specification Heading
  ## Vowel counts in single word     ✔ ✔
  ## Vowel counts in multiple word   ✔ ✔

Successfully generated html-report to => hello_gauge/reports/html-report
Specifications: 1 executed  1 passed    0 failed    0 skipped
Scenarios:  2 executed  2 passed    0 failed    0 skipped

Total time taken: 93ms

レポートの確認

出力されたHTMLレポートを確認してみます。
report.png

まとめ

Gaugeの概要、利用方法についてまとめました。
今後は、実際のテスト仕様・実装の記述や日本語利用を試して行きます。

9
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
10