質問

フィットを使って統合/承認テストを作成しようとしています。これがフォルダ構造:です。

-src
--main
---fit
----"html files"
---java
----fit
-----"FIT Fixtures files"
----my
-----package
------"business logic files"
.

これは私のpom.xml(maven2):

<project ...>
    <modelVersion>4.0.0</modelVersion>
    <groupId>test</groupId>
    <artifactId>Test</artifactId>
    <version>1.0-SNAPSHOT</version>
    <dependencies>
        ...
        <dependency>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>fit-maven-plugin</artifactId>
            <version>2.0-beta-3</version>
        </dependency>
    </dependencies>
    <build>
        <sourceDirectory>src/main/java</sourceDirectory>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>fit-maven-plugin</artifactId>
                <version>2.0-beta-3</version>
                <executions>
                    <execution>
                        <configuration>
                            <sourceDirectory>src/main/fit</sourceDirectory>
                            <sourceIncludes>*.html</sourceIncludes>
                            <outputDirectory>${project.basedir}\target</outputDirectory>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <repositories>
        ...
    </repositories>
</project>
.

mvn integration-test -Xを使用したフィットテストの実行、次のようにエラーが発生します。

java.lang.IllegalStateException:フィクスチャが失敗しました カウント数:0右、0間違った、0無視、4例外

それでも、C:\JavaTest\target\customer-bills.htmlのFIT出力が生成され、エラーが表示されます。 java.lang.RuntimeException: The fixture GivenTheFollowingCustomers was not found.

"GiventeFollingCustomers"はHTMLのテーブルヘッダーです。

<table>
    <tr>
        <td colspan="3" class="title">GivenTheFollowingCustomers</td>
    </tr>
    ...
</table>
.

私はシステムはGivenTheFollowingCustomersというフィクスチャを探していたと思いましたか?なぜそれが見つけることができないのか?

ありがとうございました!

更新: システムは最初のテーブルのフィクスチャを見つけることができますが、最初のものだけです。テーブルヘッダーはGivenTheFollowingCustomersの代わりにfit.GivenTheFollowingCustomersであるため、問題に直面していました。それでも、そのHTMLファイル内の他のすべてのテーブル/備品にも同じエラーが発生しています。それは特定のテーブルに依存しないので、それは奇妙です。たとえば、2番目の位置に最初のテーブル(GivenTheFollowingCustomers)を移動すると、動作が停止し、最初のものが代わりに作業を開始します。任意の手がかり。?

update2:私はフィットライブラリ(Mavenなしで)を使って手動でテストを実行しようとしました。また、他の人はこれを書いています。 http:// osdir.com/ml/java.maven-plugins.mojo.user/2007-07/msg00000.html と答えがなかった。フィットマーベンプラグインの可能なバグは?

役に立ちましたか?

解決

It is a known bug with the FIT maven plugin. The fix should have been released in version 2.0-beta-4 but it has never been released. In fact, it seems like development stopped in December 2007 (ouch!). Anyway, it's possible to solve the problem by creating the following class (as seen in the patch):

/**
 * Extends ColumnFixture to allow a custom ClassLoader to be used for loading fixtures
 * 
 * @author Mauro Talevi
 */
public class ClassLoaderColumnFixture
    extends ColumnFixture
    implements FixtureClassLoaderEnabled
{

    private FixtureClassLoader classLoader;

    public ClassLoaderColumnFixture()
    {
        this( new FixtureClassLoader() );
    }

    public ClassLoaderColumnFixture()
    {
        this( new FixtureClassLoader() );
    }

    public ClassLoaderColumnFixture( FixtureClassLoader classLoader )
    {
        this.classLoader = classLoader;
    }

    public void enableClassLoader( FixtureClassLoader classLoader )
    {
        this.classLoader = classLoader;
    }

    public Fixture loadFixture( String fixtureName )
        throws InstantiationException, IllegalAccessException
    {
        return classLoader.newFixture( fixtureName );
    }
}

And extending from ClassLoaderColumnFixture instead of ColumnFixtures in the fixtures.

This solved my problem, I hope it will be helpful for someone else.

他のヒント

There is a new maven plugin for fit you can use. Just replace the plugin with:

<plugin>
  <groupId>com.github.cradloff</groupId>
  <artifactId>fit-maven-plugin</artifactId>
  <version>3.0</version>
  <executions>
    <execution>
      <id>fixture</id>
      <phase>test</phase>
      <goals>
        <goal>run</goal>
      </goals>
    </execution>
  </executions>
</plugin>

Then there is no need for a special Class Loader Fixture.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top