0

次のコマンドを実行すると、奇妙なエラーが発生します。

テストクラス:

    @ContextConfiguration(locations={"classpath:META-INF/spring-context.xml","classpath:META-INF/spring-context-test.xml"})
    public class LoginServiceTest extends AbstractJUnit4SpringContextTests{
        @Autowired
        private LoginServiceTestCase loginTestCase;

        @Before
        public void setup() {
        loginTestCase.initialize();
        }

        @After
        public void teardown() {
        }


    @Test
    public void testLoginWithValidAccount() throws Exception {
    loginTestCase.setTestName("Validate Login with valid credentials");
    loginTestCase.setTestCondition(loginTestCase.CONDITION_USERNAME, "...");
    loginTestCase.setTestCondition(loginTestCase.CONDITION_PASSWORD, "...");
    loginTestCase.setExpectedResult(loginTestCase.RESULT_IS_ERROR, false);
    assertTrue(loginTestCase.isTestPass());
    }
....
}

テストするケース:

public class LoginServiceTestCase extends TestCase{
    @Autowired
    private LoginService loginService; // the class to be tested
    ......
    protected void executeTest() throws Exception {
    try {
.....   } catch (Exception e) {
    isError = true;
    }
    } 

build.xml:

<target name="compile" >
        <echo message="-----> Compile Classes from ${src}" />
        <mkdir dir="${build}/classes" />
        <javac  srcdir="${src}"
                includes="**/*.java"
                destdir="${build}/classes"
                debug="on">
            <classpath refid="dependencies"/>
        </javac>
        <copy todir="${build}/classes/META-INF">
            <fileset dir="${basedir}/config" includes="**"/>
        </copy>
    </target>

<target name="batch-test" >
        <mkdir dir="${reports.tests}"/>
        <junit printsummary="yes" haltonfailure="yes">
          <classpath>
            <pathelement location="${build}/classes"/>
            <path refid="dependencies"/>
          </classpath>

          <formatter type="plain"/>
          <formatter type="xml"/>

          <batchtest fork="yes" todir="${reports.tests}">
            <fileset dir="${src}">
              <include name="**/*Test.java"/>
            </fileset>
          </batchtest>
        </junit>
    </target>

どこが間違っていますか?

4

1 に答える 1

0

この質問を閉じたかったのですが、問題が ant バージョンにあったことを伝えたかっただけです。ant 1.5 から 1.7 に移行すると、問題が解決されました。

于 2013-02-09T05:15:53.583 に答える