Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6711655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:09:58+00:00 2026-05-26T08:09:58+00:00

I am automating my JUnit tests into my Ant build. However, my simple test

  • 0

I am automating my JUnit tests into my Ant build. However, my simple test only passes when run from the IDE and commandline but fails with Ant’s <junit> task. When I run it from the commandline (I am technically using the Ant <exec> task) the result is:

clean:

compile_tests:
    [javac] Compiling 2 source files to C:\MY_TEMP

junit_exec:
     [exec] JUnit version 4.10
     [exec] .
     [exec] Time: 0.004
     [exec]
     [exec] OK (1 test)
     [exec]

BUILD SUCCESSFUL
Total time: 1 second

but when I use the <junit> task:

Buildfile: C:\MY_TEMP\build.xml

clean:

compile_tests:
    [javac] Compiling 2 source files to C:\MY_TEMP

junit_ant:
     [echo] junit_ant started
    [junit] Test SimpleTest FAILED

BUILD SUCCESSFUL
Total time: 0 seconds

The contents of MY_TEMP are junit-4.10.jar, SimpleTest.java, and build.xml.

I have copied junit-4.10.jar to the %ANT_HOME%\lib folder as suggest by the Ant junit task documentation. It already had both ant-junit.jar and ant-junit4.jar.

My version of Java is 1.6.0_26.

My test is:

// YES, this is the default package
import org.junit.*;

public class SimpleTest {

    @Test
    public void mySimpleTest(){
        Assert.assertEquals(  2,  1 + 1  );
    }

}

And my Ant file (build.xml ), is:

<?xml version="1.0"?>
<project name="regression_tests" basedir=".">

    <target name="clean">
        <delete>
            <fileset dir="." includes="*.class" />
        </delete>
    </target>

    <target name="compile_tests" depends="clean">
            <javac srcdir="." destdir="." source="1.6" target="1.6" includeantruntime="false" >
            <classpath>
                <pathelement location="./junit-4.10.jar" />
            </classpath>
        </javac>
    </target>

    <target name="junit_ant" depends="compile_tests" >
        <echo message="junit_ant started" />

        <junit>
            <test name="SimpleTest" />
        </junit>
    </target>

    <target name="junit_exec" depends="compile_tests">
        <exec executable="java" dir="." >
            <arg value="-classpath" />
            <arg value=".;junit-4.10.jar" />
            <arg value="org.junit.runner.JUnitCore" />
            <arg value="SimpleTest" />
        </exec>
    </target>

</project>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T08:09:59+00:00Added an answer on May 26, 2026 at 8:09 am

    If a test passes one way, and fails another, it’s likely something classpath-related, like it can’t find a test class, a class under test, or a library.

    The test output should help clarify if this is what the issue is.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently looking into automating a flex build so that we can get it
I am having trouble defining and automating my build process despite simple requirements: Every
I use junit automatically installed by maven. When I run the maven test my
So I created a new Android junit test, which runs my ui-automation tests (Robotium,
Our Team is automating tests/test data preparation in QTP and we do the scripting
I'm automating Visio 2003 from a VB.NET app. My code looks like this (with
I am automating Microsoft Access from C# like so: using Microsoft.Office.Interop.Access; static void Main(string[]
I've been automating some tests against a web application using Python and COM. My
I'm trying to automating some tests for an Excel add-in, which is in xll
I'm automating my MSBuild-based C# solution build using Hudson running on a Windows machine.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.