Concordion-asserttrue-command

提供:Dev Guides
移動先:案内検索

一致-assertTrueコマンド

Concordion assertTrueコマンドは、テストを実行するためにフィクスチャーが期待される結果を知る必要がある場合に使用されます。

次の要件を考慮してください-

User Name : Robert De
The User name starts with R.
The User name starts with S == false.

ユーザー名でテストを実行し、ユーザー名がRで始まるかどうかを確認する場合。

<p>User Name :<span concordion:set = "#userName">Robert De</span></p>
<p>The User name <span concordion:assertTrue = "#userName.startsWith(#letter)">starts
   with <b concordion:set = "#letter">R</b></span>.</p>
<p>The User name <span concordion:assertTrue = "#userName.startsWith(#letter)">starts
   with <b concordion:set = "#letter">S</b></span>.</p>

Concordionがドキュメントを解析するとき、一時変数#userNameを値「Robert De」に設定します。 次に、userNameが次のコマンドで設定された#letter変数で指定された文字で始まるかどうかを確認します。

動作するEclipse IDEを用意し、以下の手順に従ってConcordionアプリケーションを作成します-

Step Description
1 Create a project with a name concordion and create a package com.finddevguides under the src folder in the created project.
2 Add the required Concordion libraries using Add External JARs option as explained in the Concordion - First Application chapter.
3 Create Java class System under the com.finddevguides package.
4 Create Fixture class SystemFixture under the specs.finddevguides package.
5 Create Specification html Systeml under the specs.finddevguides package.
6 The final step is to create the content of all the Java files and specification file and run the application as explained below.

System.javaファイルの内容は次のとおりです-

package com.finddevguides;
public class System {
}

SystemFixture.javaファイルの内容は次のとおりです-

package specs.finddevguides;

import org.concordion.integration.junit4.ConcordionRunner;
import org.junit.runner.RunWith;

@RunWith(ConcordionRunner.class)

public class SystemFixture {
}

以下は、Systemlファイルの内容です-

<html xmlns:concordion = "http://www.concordion.org/2007/concordion">
   <head>
      <link href = "../concordion.css" rel = "stylesheet" type = "text/css"/>
   </head>

   <body>
      <h1>System Specifications</h1>
      <p>We are building specifications for our online order tracking application.</p>
      <p>Following is the requirement to split full name of a logged in user to
         its constituents by splitting name by whitespace:</p>

      <div class = "example">
         <h3>Example</h3>
         <p>User Name :<span concordion:set = "#userName">Robert De</span></p>
         <p>The User name <span concordion:assertTrue = "#userName.startsWith(#letter)">starts
            with <b concordion:set = "#letter">R</b></span>.</p>
         <p>The User name <span concordion:assertTrue = "#userName.startsWith(#letter)">starts
            with <b concordion:set = "#letter">S</b></span>.</p>
      </div>

   </body>

</html>

ソースファイルと仕様ファイルの作成が完了したら、アプリケーションをJUnitテストとして実行します。 すべてがあなたのアプリケーションでうまくいけば、それは次の結果を生成します-

C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\concordion\specs\finddevguides\Systeml
Successes: 1, Failures: 1

システムは、Concordionテスト実行の出力です。

concordion assertTrueコマンド出力