0
votes

My junit test class uses a dll to connect to the database. When I run the test from eclipse, it works fine, but when I use ant to run the test, I got this:

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)

This is the ant target in my 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>

To avoid problems about the inclusion of the dll, I included it in the PATH environment variable. Is there anything I am missing in the target to complete the execution of the test?

Thanks in advance.

1

1 Answers

0
votes

Finally the issue was that I was missing the .jar from which the java operations are taken from (sqljdbc42.jar). Including it in the classpath solved the issue.