DLL 未由 ant 执行的 junit 测试加载

DLL not loaded by junit test executed from ant

我的junit 测试class 使用dll 连接到数据库。当我 运行 从 eclipse 进行测试时,它工作正常,但是当我使用 ant 进行 运行 测试时,我得到了这个:

Testsuite: ......BatchAlertTest Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0,064 sec

Testcase: testAddAlert took 0,002 sec FAILED com.microsoft.sqlserver.jdbc.SQLServerDriver junit.framework.AssertionFailedError: com.microsoft.sqlserver.jdbc.SQLServerDriver at ......BatchAlertTest.createDatabaseConnection(BatchAlertTest.java:44) at ......BatchAlertTest.setUp(BatchAlertTest.java:32)

这是我的蚂蚁目标 build.xml:

<target name="run-persister-junit">
    <mkdir dir="testReports"/>

    <junit printsummary="yes" haltonfailure="yes">

        <classpath>
            <pathelement location="java/lib/JUnit/junit-4.12.jar"/>
            <pathelement location="java/lib/JUnit/hamcrest-core-1.3.jar"/>
            <pathelement location="java/bin"/>

        </classpath>

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

        <batchtest fork="yes" todir="testReports">
            <fileset dir="java/bin">
                <include name="/**/*Test.class"/>
            </fileset>
        </batchtest>

    </junit>

</target>

为了避免有关包含 dll 的问题,我将其包含在 PATH 环境变量中。我在完成测试执行的目标中是否遗漏了什么?

提前致谢。

最后的问题是我丢失了从中获取 java 操作的 .jar (sqljdbc42.jar)。将它包含在类路径中解决了这个问题。