簡體   English   中英

從ant執行的junit測試未加載DLL

[英]DLL not loaded by junit test executed from ant

我的junit測試類使用dll連接到數據庫。 當我從eclipse運行測試時,它工作正常,但是當我使用ant運行測試時,我得到了:

測試套件:...... BatchAlertTest測試運行:1,故障:1,錯誤:0,跳過:0,經過的時間:0,064秒

測試案例:testAddAlert在...... BatchAlertTest.createDatabaseConnection(BatchAlertTest.java:44)處的com.microsoft.sqlserver.jdbc.SQLServerDriver在...... BatchAlertTest.createDatabaseConnection(BatchAlertTest.java:44)處失敗了002 sec com.microsoft.sqlserver.jdbc.SQLServerDriver失敗。 ..... BatchAlertTest.setUp(BatchAlertTest.java:32)

這是我的build.xml中的ant目標:

<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)。 將其包含在類路徑中可以解決此問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM