2012-03-01 5 views
1

FITを使用して統合/受け入れテストを作成しようとしています。ここではフォルダ構造は次のとおりです。MavenでFITビルドに失敗しました

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

は私のpom.xmlが(Maven2を)です:

mvn integration-test -Xを使用してFITテストを実行
<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> 

、私はによって引き起こされるエラーを取得する:

java.lang.IllegalStateException:フィクスチャが で失敗した回数:0右、0間違った、0無視、4つの例外

それでも、C:\JavaTest\target\customer-bills.htmlにおけるFIT出力が生成され、というエラーが含まれている: java.lang.RuntimeException: The fixture GivenTheFollowingCustomers was not found.

「GivenTheFollowingCustomers」をHTMLのテーブルヘッダーです:

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

私は、システムが探しているだろうと思いました什器はGivenTheFollowingCustomers?なぜそれを見つけることができないのですか?

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

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

更新2:私はFITライブラリ(Mavenなし)で手動でテストを実行しようとしましたが、うまくいきました!また、誰かがこれを書きました:http://osdir.com/ml/java.maven-plugins.mojo.user/2007-07/msg00000.htmlと回答がありませんでした。 FIT mavenプラグインのバグがありますか?

答えて

1

FIT mavenプラグインを使用してknown bugです。修正は、バージョン2.0-beta-4でリリースされているはずですが、リリースされたことはありません。実際には、2007年12月に開発が中止されたようです(ああ!)。

/** 
* 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); 
    } 
} 

そしてClassLoaderColumnFixture代わりの備品でColumnFixturesから延びる:とにかく、それは次のクラスを(パッチに見られるように)作成することによって、問題を解決することが可能です。

これは私の問題を解決しました。他の人にとって役立つことを願っています。

0

使用できるフィット感のための新しいmavenプラグインがあります。プラグインを次のように置き換えてください:

<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> 

次に、特別なクラスローダーフィクスチャーは必要ありません。

関連する問題