1

uk.co.javahelp.fitnesse から fitnesse-launcher-maven-plugin をインストールしたところ、正常に動作することがわかります。

ここで、いくつかのテストを作成し、ビルド中に表示および実行したいと考えています。

私の pom.xml ファイルには、次のプラグインが含まれています。

  <profiles>
    <profile>
      <id>wiki</id>
      <build>
        <plugins>
          <plugin>
            <groupId>uk.co.javahelp.fitnesse</groupId>
            <artifactId>fitnesse-launcher-maven-plugin</artifactId>
            <version>1.4.2</version>
            <executions>
              <execution>
                <goals>
                  <goal>set-up</goal>
                  <goal>wiki</goal>
                  <goal>tear-down</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>auto</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>uk.co.javahelp.fitnesse</groupId>
            <artifactId>fitnesse-launcher-maven-plugin</artifactId>
            <configuration>
              <failIfNoTests>false</failIfNoTests>
            </configuration>
            <executions>
              <execution>
                <goals>
                  <goal>set-up</goal>
                  <goal>run-tests</goal>
                  <goal>tear-down</goal>
                  <goal>verify</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

次のプラグイン Web サイトのドキュメントに従います。

http://fitnesse-launcher-maven-plugin.googlecode.com

また、次のディレクトリと空の (今のところ) ファイルも作成しました。

stephane@stephane-ThinkPad-X301:toolbox> tree src/test/java/fitnesse/
src/test/java/fitnesse/
├── FirstTestSuite
│   ├── content.txt
│   ├── NestedSuite
│   │   ├── AnIndividualTest
│   │   │   ├── content.txt
│   │   │   └── properties.xml
│   │   ├── content.txt
│   │   └── properties.xml
│   ├── properties.xml
│   └── Setup
│       ├── content.txt
│       └── properties.xml
└── plugins.properties

コマンドを実行する場合:

mvn verify -P wiki

それから私はで見ることができます

http://localhost:9123/

私のものではないいくつかのデフォルトのFitnesseテスト。

一方、コマンドを実行すると:

mvn verify

実行するテストはありません。

[INFO] Executed tasks
[INFO] 
[INFO] --- fitnesse-launcher-maven-plugin:1.4.2:run-tests (default) @ toolbox ---
[INFO] ------------------------------------------------------------------------
[INFO] Setting FitNesse variable [maven.classpath] to [
!path /home/stephane/dev/java/projects/toolbox/target/test-classes
!path /home/stephane/dev/java/projects/toolbox/target/classes
!path /home/stephane/.m2/repository/org/fitnesse/fitnesse/20140201/fitnesse-20140201.jar
!path /home/stephane/.m2/repository/org/htmlparser/htmlparser/2.1/htmlparser-2.1.jar
!path /home/stephane/.m2/repository/org/htmlparser/htmllexer/2.1/htmllexer-2.1.jar
!path /home/stephane/.m2/repository/org/apache/velocity/velocity/1.7/velocity-1.7.jar
!path /home/stephane/.m2/repository/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar
!path /home/stephane/.m2/repository/commons-lang/commons-lang/2.4/commons-lang-2.4.jar
!path /home/stephane/.m2/repository/org/json/json/20090211/json-20090211.jar
!path /home/stephane/.m2/repository/com/googlecode/java-diff-utils/diffutils/1.2.1/diffutils-1.2.1.jar
!path /home/stephane/.m2/repository/org/eclipse/jgit/org.eclipse.jgit/2.3.1.201302201838-r/org.eclipse.jgit-2.3.1.201302201838-r.jar
!path /home/stephane/.m2/repository/com/jcraft/jsch/0.1.46/jsch-0.1.46.jar
]
[INFO] Setting FitNesse variable [org.springframework.version] to [4.2.0.RELEASE]
[INFO] Setting FitNesse variable [java.version] to [1.8.0_60]
[INFO] Setting FitNesse variable [org.springframework.security.version] to [3.2.5.RELEASE]
[INFO] Setting FitNesse variable [project.build.sourceEncoding] to [UTF-8]
[INFO] Setting FitNesse variable [artifact] to [toolbox]
[INFO] Setting FitNesse variable [version] to [0.0.1-SNAPSHOT]
[INFO] Setting FitNesse variable [basedir] to [/home/stephane/dev/java/projects/toolbox]
[INFO] ------------------------------------------------------------------------
[WARNING] No FitNesse Suites or Tests to run! (Set -Dfitnesse.fitnesse.failIfNoTests=false to ignore.)
[INFO] 0 right, 0 wrong, 0 ignored, 0 exceptions
[INFO] 
[INFO] --- fitnesse-launcher-maven-plugin:1.4.2:tear-down (default) @ toolbox ---
[INFO] 
[INFO] --- fitnesse-launcher-maven-plugin:1.4.2:verify (default) @ toolbox ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.061 s
[INFO] Finished at: 2015-10-26T10:25:17+01:00
[INFO] Final Memory: 19M/205M
[INFO] ------------------------------------------------------------------------
stephane@stephane-ThinkPad-X301:toolbox>

ビジネス ロジックの add(2, 2) メソッドが 4 を返すことを確認するなど、Slim フィクスチャを使用して非常に単純な Java テストを作成したいと考えています。

wiki テストはどのファイルに入れる必要がありますか? どのファイルにフィクスチャを入れるべきですか? Fitnesse にテストを実行するように指示する方法は?

更新:私の例のフィクスチャは次のとおりです。

public class ExampleFixture {

    private String value;
    private String result;

    public ExampleFixture() {
    }

    public void execute() {
        if (value != null) {
            result = Common.trimSpaces(value);
        }
    }

    public void setValue(String value) {
        this.value = value;
    }

    public String getResult() {
        return result;
    }

}

およびその内容:

|Example fixture|
|value|result?|
|some space|somespace|

最後の問題、result[0] が見つからないという問題は、フィクスチャ コンテンツの getResult ではなく、getter が結果を読み取ったことが原因でした。|値|getResult?| |いくつかのスペース|いくつかのスペース|

4

1 に答える 1

2

あなたはフィットネスコードを下に置きましたsrc/test/java/fitnesse/

デフォルトの場所は実際には次のとおりです: src/test/fitnesse/(を削除しますjava)

または、 でpom.xml、使用するディレクトリを構成します。

<testResourceDirectory>src/test/fitnesse</testResourceDirectory>

プラグイン構成ドキュメントを参照してください。


アップデート:

googlecode が廃止されたため、アーカイブ サイトは一部のリンクに対して 404 を返します。いつの日かそれを修正することができるかもしれません。一方、プロジェクトはGithubで入手できます。作成したHTMLをブラウザで実行maven siteしてアクセスすれば、ドキュメントはすべて揃っているはずです。

于 2015-10-26T09:39:27.923 に答える