Skip to content

Commit 0523b64

Browse files
committed
updated docs for testcase.
1 parent a631e69 commit 0523b64

File tree

3 files changed

+53
-74
lines changed

3 files changed

+53
-74
lines changed

docs/ch/user-guide/test/index.md

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ void create_data();
3737
void TestBlog::create_data()
3838
{
3939
// 定义测试数据
40-
QTest::addColumn<QString>("title");
40+
QTest::addColumn<QString>("title");
4141
QTest::addColumn<QString>("body");
4242
//增加测试数据
4343
QTest::newRow("No1") << "Hello" << "Hello world.";
@@ -46,14 +46,14 @@ void TestBlog::create_data()
4646
void TestBlog::create()
4747
{
4848
// 获取测试数据
49-
QFETCH(QString, title);
49+
QFETCH(QString, title);
5050
QFETCH(QString, body);
5151
//测试的逻辑
5252
Blog created = Blog::create(title, body);
5353
int id = created.id();
5454
Blog blog = Blog::get(id); // 获取模型 ID
5555
//检查结果的执行
56-
QCOMPARE(blog.title(), title);
56+
QCOMPARE(blog.title(), title);
5757
QCOMPARE(blog.body(), body);
5858
}
5959
TF_TEST_MAIN( TestBlog)// 指定你创建的类名
@@ -79,9 +79,9 @@ TF_TEST_MAIN( TestBlog)// 指定你创建的类名
7979
```
8080
TARGET = testblog
8181
TEMPLATE = app
82-
CONFIG += console debug qtestlib
82+
CONFIG += console debug c++11
8383
CONFIG -= app_bundle
84-
QT += network sql
84+
QT += network sql testlib
8585
QT -= gui
8686
DEFINES += TF_DLL
8787
INCLUDEPATH += ../..
@@ -90,18 +90,12 @@ include(../../appbase.pri)
9090
SOURCES = testblog.cpp # 指定文件名
9191
```
9292
93-
Qt5以后有些规范已经更改了. 如果使用Qt5, 请更改上面的第5行如下.
94-
95-
```
96-
QT += network sql testlib
97-
```
98-
9993
在你保存项目文件后, 你可以通过下面的命令在目录生成一个二进制文件.
10094
10195
```
10296
$ qmake
10397
$ make
104-
```
98+
```
10599
106100
接下来, 要执行测试过程,一些配置需要完成.
107101
因为需要引用各种配置文件, 测试命令需要一个配置目录的符号连接. 它的位置应该直接在测试命令下. 当使用SQLite数据库时, 我们也需要生成一个符号连接到*db*文件夹.
@@ -115,7 +109,7 @@ $ ln -s ../../db db
115109
要创建一个符号连接, 必须有管理员权限从命令行窗口运行命令.
116110
117111
```
118-
> cd debug
112+
> cd debug
119113
> mklink /D config ..\..\..\config
120114
> mklink /D db ..\..\..\db
121115
```
@@ -150,12 +144,11 @@ ConnectOptions=
150144
151145
```
152146
$ ./testblog
153-
********* Start testing of TestBlog *********
154-
Config: Using QTest library 4.8.3, Qt 4.8.3
147+
Config: Using QtTest library 5.5.1, Qt 5.5.1 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 5.4.0 20160609)
155148
PASS : TestBlog::initTestCase()
156-
PASS : TestBlog::create()
149+
PASS : TestBlog::create(No1)
157150
PASS : TestBlog::cleanupTestCase()
158-
Totals: 3 passed, 0 failed, 0 skipped
151+
Totals: 3 passed, 0 failed, 0 skipped, 0 blacklisted
159152
********* Finished testing of TestBlog *********
160153
```
161154
@@ -164,15 +157,15 @@ Totals: 3 passed, 0 failed, 0 skipped
164157
165158
```
166159
********* Start testing of TestBlog *********
167-
Config: Using QTest library 4.8.3, Qt 4.8.3
168-
PASS : TestBlog::initTestCase()
169-
FAIL!: TestBlog:: create( No1) Compared values are not the same
170-
Actual (blog.body()): foo bar.
171-
Expected (body): Hello world.
172-
Loc: [testblog.cpp(33)]
173-
PASS : TestBlog::cleanupTestCase()
174-
Totals: 2 passed, 1 failed, 0 skipped
175-
********* Finished testing of TestBlog *********
160+
Config: Using QtTest library 5.5.1, Qt 5.5.1 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 5.4.0 20160609)
161+
PASS : TestBlog::initTestCase()
162+
FAIL! : TestBlog::create(No1) Compared values are not the same
163+
Actual (blog.body()): "foo."
164+
Expected (body): "Hello world."
165+
Loc: [testblog.cpp(35)]
166+
PASS : TestBlog::cleanupTestCase()
167+
Totals: 2 passed, 1 failed, 0 skipped, 0 blacklisted
168+
********* Finished testing of TestBlog *******
176169
```
177170
178-
为每个模型生成一个测试用例, 然后执行这个测试.一个好的网页应用开发的关键是确保模型(model)正确工作.
171+
为每个模型生成一个测试用例, 然后执行这个测试.一个好的网页应用开发的关键是确保模型(model)正确工作.

docs/en/user-guide/test/index.md

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Let's test the Blog model code that we made in the [tutorial](/user-guide/en/tut
2020
```
2121

2222
We will try to create the test case for creating and reading of the Blog model.<br>
23-
For example, let's set the name of the implementing test as follows: *TestBlog*. The source code with the following content is saved as a file named *testBlog.cpp*.
23+
For example, let's set the name of the implementing test as follows: *TestBlog*. The source code with the following content is saved as a file named *testblog.cpp*.
2424

2525
```c++
2626
#include <TfTest/TfTest>
@@ -83,9 +83,9 @@ Next, create a project file to make the *Makefile*. The file name is *testblog.p
8383
```
8484
TARGET = testblog
8585
TEMPLATE = app
86-
CONFIG += console debug qtestlib
86+
CONFIG += console debug c++11
8787
CONFIG -= app_bundle
88-
QT += network sql
88+
QT += network sql testlib
8989
QT -= gui
9090
DEFINES += TF_DLL
9191
INCLUDEPATH += ../..
@@ -94,12 +94,6 @@ Next, create a project file to make the *Makefile*. The file name is *testblog.p
9494
SOURCES = testblog.cpp # Specifying the file name
9595
```
9696
97-
Part of the specification has changed after the update to Qt5. If you are using Qt5, please change the 5th line of the above as the following.
98-
99-
```
100-
QT += network sql testlib
101-
```
102-
10397
After you save the project file, you can create a binary by running the following command in its directory:
10498
10599
```
@@ -154,12 +148,11 @@ The configuration is now complete. Next, the test needs to be executed. If the t
154148
155149
```
156150
$ ./testblog
157-
********* Start testing of TestBlog *********
158-
Config: Using QTest library 4.8.3, Qt 4.8.3
151+
Config: Using QtTest library 5.5.1, Qt 5.5.1 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 5.4.0 20160609)
159152
PASS : TestBlog::initTestCase()
160-
PASS : TestBlog::create()
153+
PASS : TestBlog::create(No1)
161154
PASS : TestBlog::cleanupTestCase()
162-
Totals: 3 passed, 0 failed, 0 skipped
155+
Totals: 3 passed, 0 failed, 0 skipped, 0 blacklisted
163156
********* Finished testing of TestBlog *********
164157
```
165158
@@ -168,15 +161,15 @@ If, however, the result is not what was expected, you will see the following mes
168161
169162
```
170163
********* Start testing of TestBlog *********
171-
Config: Using QTest library 4.8.3, Qt 4.8.3
164+
Config: Using QtTest library 5.5.1, Qt 5.5.1 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 5.4.0 20160609)
172165
PASS : TestBlog::initTestCase()
173166
FAIL! : TestBlog::create(No1) Compared values are not the same
174-
Actual (blog.body()): foo bar.
175-
Expected (body): Hello world.
176-
Loc: [testblog.cpp(33)]
167+
Actual (blog.body()): "foo."
168+
Expected (body): "Hello world."
169+
Loc: [testblog.cpp(35)]
177170
PASS : TestBlog::cleanupTestCase()
178-
Totals: 2 passed, 1 failed, 0 skipped
179-
********* Finished testing of TestBlog *********
171+
Totals: 2 passed, 1 failed, 0 skipped, 0 blacklisted
172+
********* Finished testing of TestBlog *******
180173
```
181174
182-
Make a test case for each each model. Then please do the test. The key to a good Web application development is to be sure that the model is working properly.
175+
Make a test case for each each model. Then please do the test. The key to a good Web application development is to be sure that the model is working properly.

docs/ja/user-guide/test/index.md

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ create() メソッドでは次の処理を行なっています。
8383
```
8484
TARGET = testblog
8585
TEMPLATE = app
86-
CONFIG += console debug qtestlib
86+
CONFIG += console debug c++11
8787
CONFIG -= app_bundle
88-
QT += network sql
88+
QT += network sql testlib
8989
QT -= gui
9090
DEFINES += TF_DLL
9191
INCLUDEPATH += ../..
@@ -94,12 +94,6 @@ create() メソッドでは次の処理を行なっています。
9494
SOURCES = testblog.cpp # ファイル名を指定する
9595
```
9696
97-
Qt5 になって一部仕様が変わりました。Qt5 を使用している場合、上記5行目を次のように設定してください。
98-
99-
```
100-
QT += network sql testlib
101-
```
102-
10397
プロジェクトファイルを保存したら、そのディレクトリで次のコマンドを実行してバイナリを作成します。
10498
10599
```
@@ -152,29 +146,28 @@ Windows の場合には、PATH 変数に設定を追加します。
152146
以上で設定は完了です。それでは、テストを実行してみましょう。テストが成功すれば、次のようなメッセージが表示されます。Windows の場合には、TreeFrog Command Prompt 上で実行してください。
153147
154148
```
155-
$ ./testblog
156-
********* Start testing of TestBlog *********
157-
Config: Using QTest library 4.8.3, Qt 4.8.3
158-
PASS : TestBlog::initTestCase()
159-
PASS : TestBlog::create()
160-
PASS : TestBlog::cleanupTestCase()
161-
Totals: 3 passed, 0 failed, 0 skipped
162-
********* Finished testing of TestBlog *********
149+
$ ./testblog
150+
Config: Using QtTest library 5.5.1, Qt 5.5.1 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 5.4.0 20160609)
151+
PASS : TestBlog::initTestCase()
152+
PASS : TestBlog::create(No1)
153+
PASS : TestBlog::cleanupTestCase()
154+
Totals: 3 passed, 0 failed, 0 skipped, 0 blacklisted
155+
********* Finished testing of TestBlog *********
163156
```
164157
165158
もし期待した結果と一致しなければ、次のようなメッセージが表示されるでしょう。
166159
167160
```
168-
********* Start testing of TestBlog *********
169-
Config: Using QTest library 4.8.3, Qt 4.8.3
170-
PASS : TestBlog::initTestCase()
171-
FAIL! : TestBlog::create(No1) Compared values are not the same
172-
Actual (blog.body()): foo bar.
173-
Expected (body): Hello world.
174-
Loc: [testblog.cpp(33)]
175-
PASS : TestBlog::cleanupTestCase()
176-
Totals: 2 passed, 1 failed, 0 skipped
177-
********* Finished testing of TestBlog *********
161+
********* Start testing of TestBlog *********
162+
Config: Using QtTest library 5.5.1, Qt 5.5.1 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 5.4.0 20160609)
163+
PASS : TestBlog::initTestCase()
164+
FAIL! : TestBlog::create(No1) Compared values are not the same
165+
Actual (blog.body()): "foo."
166+
Expected (body): "Hello world."
167+
Loc: [testblog.cpp(35)]
168+
PASS : TestBlog::cleanupTestCase()
169+
Totals: 2 passed, 1 failed, 0 skipped, 0 blacklisted
170+
********* Finished testing of TestBlog *******
178171
```
179172
180-
モデルごとにテストケースを作成し、どんどんテストを行なってください。モデルがきちんと動作するかどうかが、Web アプリの要(かなめ)となるのです。
173+
モデルごとにテストケースを作成し、どんどんテストを行なってください。モデルがきちんと動作するかどうかが、Web アプリの要(かなめ)となるのです。

0 commit comments

Comments
 (0)