문제

FIT를 사용하여 통합/수락 테스트를 만들려고 합니다.폴더 구조는 다음과 같습니다.

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

다음을 사용하여 FIT 테스트 실행 mvn integration-test -X, 다음 원인으로 인해 오류가 발생합니다.

java.lang.IllegalStateException:픽스팅은 카운트로 실패했습니다.0개 맞음, 0개 틀림, 0개 무시, 4개 예외

그래도 FIT 출력은 C:\JavaTest\target\customer-bills.html 생성되었으며 다음과 같은 오류가 포함되어 있습니다.java.lang.RuntimeException: The fixture GivenTheFollowingCustomers was not found.

"GivenTheFollowingCustomers"는 HTML의 테이블 헤더입니다.

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

나는 시스템이 다음과 같은 고정물을 찾고 있을 것이라고 생각했습니다. GivenTheFollowingCustomers?왜 그것을 찾을 수 없습니까?

매우 감사합니다!

업데이트:이제 시스템은 첫 번째 테이블의 고정물을 찾을 수 있지만 첫 번째 테이블만 찾을 수 있습니다!테이블 헤더가 다음과 같았기 때문에 문제에 직면했습니다. GivenTheFollowingCustomers 대신에 fit.GivenTheFollowingCustomers.그래도 해당 HTML 파일의 다른 모든 테이블/장치에 대해 동일한 오류가 발생합니다.그리고 특정 테이블에 의존하지 않기 때문에 이상합니다.예를 들어, 첫 번째 테이블(GivenTheFollowingCustomers) 두 번째 위치에서는 작동이 중지되고 첫 번째 위치가 대신 작동하기 시작합니다.어떤 단서라도 ..?

업데이트2: FIT 라이브러리(maven 없이)를 사용하여 수동으로 테스트를 실행해 보았는데 잘 작동합니다!또한 다른 사람이 이렇게 썼습니다. http://osdir.com/ml/java.maven-plugins.mojo.user/2007-07/msg00000.html 대답이 없었습니다.FIT Maven 플러그인에 버그가 있을 수 있습니다..?

도움이 되었습니까?

해결책

이것은 알려진 버그 FIT 메이븐 플러그인을 사용하세요.수정 사항은 버전 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 비품에서.

이로써 내 문제가 해결되었으므로 다른 사람에게도 도움이 되기를 바랍니다.

다른 팁

사용할 수 있는 새로운 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>

그러면 특별한 Class Loader Fixture가 필요하지 않습니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top