File tree Expand file tree Collapse file tree 4 files changed +59
-3
lines changed
examples/simple-api-test/src/test/kotlin Expand file tree Collapse file tree 4 files changed +59
-3
lines changed Original file line number Diff line number Diff line change 11# Enable auto-env through the sdkman_auto_env config
22# Add key=value pairs of SDKs to use below
33java=21.0.1-tem
4- maven=3.9.5
4+ maven=3.9.9
Original file line number Diff line number Diff line change 11# Playtest2
22
3- [ ![ Tests] ( https://github.com/uzabase/playtest2/actions/workflows/test.yaml/badge.svg )] ( https://github.com/uzabase/playtest2/actions/workflows/test.yaml )
3+ [ ![ Tests] ( https://github.com/uzabase/playtest2/actions/workflows/test.yaml/badge.svg )] ( https://github.com/uzabase/playtest2/actions/workflows/test.yaml )
44[ ![ JitPack] ( https://jitpack.io/v/uzabase/playtest2.svg )] ( https://jitpack.io/#uzabase/playtest2 )
5+ [ ![ Maven Central Version] ( https://img.shields.io/maven-central/v/com.uzabase.playtest2/playtest2 )] ( https://central.sonatype.com/artifact/com.uzabase.playtest2/playtest2 )
6+
7+ ## Installation
8+
9+ テストプロジェクトに必要な依存関係を記述します。Playtest2では、現在以下のモジュールを提供しています。
10+
11+ | モジュール名 | 必須 | 説明 |
12+ | -------------------| -----| ---------------------------------------|
13+ | playtest-core | [ x] | Playtest2の設定やアサーションのためのモジュール |
14+ | playtest-http | [ ] | HTTPリクエストを送信して、レスポンスを検証可能にするモジュール |
15+ | playtest-wiremock | [ ] | WireMockを使って外部APIへのリクエストを検証可能にするモジュール |
16+
17+ ## Usage
18+
19+ Playtest2では設定のためのDSLを提供しています。` playtest2 ` 関数に各モジュールが提供する設定関数(` http ` , ` wireMock ` など)で設定を追加していくことで、Playtest2が提供するステップを利用することができるようになります。
20+
21+ ``` kotlin
22+ import com.uzabase.playtest2.core.config.Configuration.Companion.playtest2
23+ import com.uzabase.playtest2.core.config.plus
24+ import com.uzabase.playtest2.http.config.http
25+ import com.uzabase.playtest2.wiremock.config.wireMock
26+
27+ class Hooks {
28+ @BeforeSuite
29+ fun beforeSuite () {
30+ playtest2 {
31+ http(URI (" http://localhost:8080" ).toURL()) +
32+ wireMock(" InnerAPI" , URI (" http://localhost:3000" ).toURL())
33+ }
34+ }
35+ }
36+ ```
37+
38+ Playtest2が提供するステップを利用すると以下のようにGaugeのスペック(` .spec ` )を記述することができます。
39+
40+ ``` example.spec
41+ # # /pingに対するテスト
42+ * パス" /ping" に
43+ * メソッド" GET" で
44+ * メディアタイプ" application/json" で
45+ * リクエストを送る
46+ * レスポンスのステータスコードが
47+ * 整数値の" 200" である
48+ ```
49+
50+ Gaugeのコンセプト(` .cpt ` )に利用することもできます。
51+
52+ ``` example.cpt
53+ # GETメソッドでパス<path>にリクエストを送る
54+ * パス<path>に
55+ * メソッド"GET"で
56+ * メディアタイプ"application/json"で
57+ * リクエストを送る
58+ ```
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ class Steps {
1515 fun beforeSuite () {
1616 playtest2 {
1717 http(URI (" http://localhost:8080" ).toURL()) +
18- wireMock(" InnerAPI" , URI (" http://localhost:3000" ).toURL())
18+ wireMock(" InnerAPI" , URI (" http://localhost:3000" ).toURL())
1919 }
2020 App .startServer()
2121 innerApi.start()
Original file line number Diff line number Diff line change 1+ before_install :
2+ - sdk e install
You can’t perform that action at this time.
0 commit comments