1
- Tests
1
+ テスト
2
2
=====
3
3
4
- Roughly speaking, there are two types of test. Unit testing allows you to
5
- test the input and output of specific functions. Functional testing allows
6
- you to command a "browser" where you browse to pages on your site, click
7
- links, fill out forms and assert that you see certain things on the page.
4
+ 大まかに言うと、テストには2つの種類が存在します。ユニットテストは、特定の関数の入力と出力をテストすることができます。機能テストは、あなたが閲覧するサイト上のページに対して "ブラウザ" を制御し、リンクをクリックしたり、フォームに記入を行ったり、ページ上の特定の物事を確認することができます。
8
5
9
- Unit Tests
6
+ ユニットテスト
10
7
----------
11
8
12
- Unit tests are used to test your "business logic", which should live in classes
13
- that are independent of Symfony. For that reason, Symfony doesn't really
14
- have an opinion on what tools you use for unit testing. However, the most
15
- popular tools are `PhpUnit `_ and `PhpSpec `_.
9
+ ユニットテストは、Symfonyから独立したクラス内に存在すべき、あなたの "ビジネスロジック" をテストするために使用されます。この理由により、Symfonyは実際のところ、ユニットテストのためにあなたがどのツールを使用するかについて意見を持ちません。しかしながら、最もポピュラーなツールは `PhpUnit `_ と `PhpSpec `_ です。
16
10
17
- Functional Tests
18
- ----------------
11
+ 機能テスト
12
+ ----------
19
13
20
- Creating really good functional tests can be tough so some developers skip
21
- these completely. Don't skip the functional tests! By defining some *simple *
22
- functional tests, you can quickly spot any big errors before you deploy them:
14
+ 真に優れた機能テストを作成することは困難であるため、一部の開発者は完全にこれを省略します。機能テストを省略しないでください!いくつかの *シンプルな * 機能テストを定義することで、いかなる大きなエラーであれ、それらをデプロイしてしまう前にすばやく発見できます。
23
15
24
16
.. best-practice ::
25
17
26
- Define a functional test that at least checks if your application pages
27
- are successfully loading.
18
+ 機能テストを定義することは、結局のところあなたのアプリケーションのページが正常にロードにされるかどうかチェックすることです。
28
19
29
- A functional test can be as easy as this :
20
+ 機能テストは以下の例のように簡単です :
30
21
31
22
.. code-block :: php
32
23
@@ -51,28 +42,20 @@ A functional test can be as easy as this:
51
42
);
52
43
}
53
44
54
- This code checks that all the given URLs load successfully, which means that
55
- their HTTP response status code is between ``200 `` and ``299 ``. This may
56
- not look that useful, but given how little effort this took, it's worth
57
- having it in your application.
45
+ このコードは全ての与えられたURLが正しくロードできることをチェックし、それは各HTTPレスポンスのステータスコードが ``200 `` から ``299 `` の間であることを意味します。
46
+ これは有用に見えないかもしれませんが、かかる労力がいかに少ないかを考慮すると、あなたのアプリケーションで行う価値があります。
58
47
59
- In computer software, this kind of test is called `smoke testing `_ and consists
60
- of *"preliminary testing to reveal simple failures severe enough to reject a
61
- prospective software release" *.
48
+ コンピュータソフトウェアにおいて、この種のテストは `smoke testing `_ と呼ばれ、 *「将来のソフトウェアリリースを退けるほど深刻な、単純な失敗を発見にするための予備的なテスト」 * で構成されます。
62
49
63
- Hardcode URLs in a Functional Test
64
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
50
+ 機能テスト内のハードコードされたURL
51
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
65
52
66
- Some of you may be asking why the previous functional test doesn't use the URL
67
- generator service:
53
+ 皆さんのうち一部の方は何故、上記の機能テストがURLジェネレータサービスを使用していないのかを尋ねるかもしれません:
68
54
69
55
.. best-practice ::
56
+ 機能テストにおいては、URLジェネレータを使用する代わりに、URLのハードコードが使用されます。
70
57
71
- Hardcode the URLs used in the functional tests instead of using the URL
72
- generator.
73
-
74
- Consider the following functional test that uses the ``router `` service to
75
- generate the URL of the tested page:
58
+ テストページのURLを生成するために ``router `` サービスを使用した、以下の機能テストについて考えてみましょう。
76
59
77
60
.. code-block :: php
78
61
@@ -85,26 +68,20 @@ generate the URL of the tested page:
85
68
// ...
86
69
}
87
70
88
- This will work, but it has one * huge * drawback. If a developer mistakenly
89
- changes the path of the `` blog_archives `` route, the test will still pass,
90
- but the original (old) URL won't work! This means that any bookmarks for
91
- that URL will be broken and you'll lose any search engine page ranking.
71
+ これは動作するでしょうが、一つ大きな欠点があります。もし開発者が `` blog_archives `` ルートのパスを誤って変更した場合、テストは未だ成功しますが、元の(古い)URLは動作しなくなるでしょう!これは、そのURLに対する全てのブックマークが壊れ、あなたが全ての検索エンジンのページランキングを失うことを意味します。
72
+
73
+ JavaScriptの機能テスト
74
+ ~~~~~~~~~~~~~~~~~~~~~~
92
75
93
- Testing JavaScript Functionality
94
- --------------------------------
76
+ 組み込みの機能テストクライアントは素晴らしいですが、それをあなたのページで、任意のJavaScriptの振る舞いをテストするために使用することはできません。もしあなたがこのテストを行う必要がある場合、PHPUnitの内部から、 `Mink `_ ライブラリを使用することを検討してください。
95
77
96
- The built-in functional testing client is great, but it can't be used to
97
- test any JavaScript behavior on your pages. If you need to test this, consider
98
- using the `Mink `_ library from within PHPUnit.
78
+ もちろん、もしもあなたが大規模なJavaScriptフロントエンドを使用している場合、純粋なJavaScriptベースのテストツールを検討すべきです。
99
79
100
- Of course, if you have a heavy JavaScript frontend, you should consider using
101
- pure JavaScript-based testing tools.
80
+ 機能テストについてさらに学ぶ
81
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
102
82
103
- Learn More about Functional Tests
104
- ---------------------------------
83
+ `Faker `_ と `Alice `_ ライブラリを使用して、あなたのテストフィクスチャのため実運用に近いデータを生成することを検討してください。
105
84
106
- Consider using `Faker `_ and `Alice `_ libraries to generate real-looking data
107
- for your test fixtures.
108
85
109
86
.. _`Faker` : https://github.com/fzaninotto/Faker
110
87
.. _`Alice` : https://github.com/nelmio/alice
0 commit comments