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

  • Home
  • SEARCH
  • 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 3210528
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T14:34:43+00:00 2026-05-17T14:34:43+00:00

When I am running a junit test from ant I always get: D:\metrike>ant test

  • 0

When I am running a junit test from ant I always get:

D:\metrike>ant test
Buildfile: build.xml

init:

compile:

test:
    [junit] Running jmt.test.TestCodeBase
    [junit] Testsuite: jmt.test.TestCodeBase
    [junit] Tests run: 1, Failures: 1, Errors: 0, Time elapsed: 0,046 sec
    [junit] Tests run: 1, Failures: 1, Errors: 0, Time elapsed: 0,046 sec
    [junit]
    [junit] Testcase: warning(junit.framework.TestSuite$1):     FAILED
    [junit] No tests found in jmt.test.TestCodeBase
    [junit] junit.framework.AssertionFailedError: No tests found in jmt.test.TestCodeBase
    [junit]
    [junit]
    [junit] Test jmt.test.TestCodeBase FAILED

This is the ant file:

<target name="test" depends="compile">
    <mkdir dir="target/test-results"/>
    <junit haltonfailure="no" printsummary="on">
        <classpath >
            <pathelement location="target/classes"/>
            <pathelement location="Libraries/junit3.8.1/junit.jar"/>
        </classpath>
        <formatter type="brief" usefile="false"/>
        <formatter type="xml" />
        <batchtest todir="target/test-results" >
            <fileset dir="target/classes" includes="**/TestCodeBase.class"/>
        </batchtest>
    </junit>
</target>

But when I manually run the test, junit test works:

D:\metrike>cd target

D:\metrike\target>cd classes

D:\metrike\target\classes>java jmt.test.TestCodeBase
fatsource.jar eclapsed : 2297 ms
over all : 2297 ms
contains 3073 classes and 3700 referred classes, 35968 referred methods, 22351 referred fields
Memory usage: 21326 KB
Post gc-memory usage: 19506 KB
contains 3073 classes and 3700 referred classes, 35968 referred methods, 22351 referred fields

Can someone please tell me what I am doing wrong? I have been trying to fix this for a whole day but I cannot find the solution.

  • 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-17T14:34:44+00:00Added an answer on May 17, 2026 at 2:34 pm

    1) Does jmt.test.TestCodeBase extend TestCase (junit.framework.TestCase)?

    If not, it will need to to be picked up by the junit ant task.

    2) Is the class written as a junit TestCase, or is it just called from the main method? See this link for an example of writing simple tests in Junit3 style. For Junit4, just add @Test above the methods.

    3) Are the test methods in Junit3 style (every method starts with test) or Junit4 style (every method has a @Test above it)?

    If Junit3, you should be good to go. If Junit4, you need to include the Junit4 test library in your ant classpath, rather than using junit3.8.1.

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

Sidebar

Related Questions

I can't figure out why I am getting this exception from my ant build.xml
I am running Junit tests from Maven. The ant script has <junit failureproperty=failproperty errorproperty=errorproperty>
Is there a way to make running junit test to stop after a test
I'm running some JUnit tests on my applications. Every test has a for loop
I am attempting to run a JUnit Test from a Java Class with: JUnitCore
When trying to start my JUnit-Test out of Eclipse, I get a ClassNotFoundException. When
Running into a problem where on certain servers we get an error that the
Running FxCop on my code, I get this warning: Microsoft.Maintainability : 'FooBar.ctor is coupled
Running OS X Leopard an MacBook Pro from Jan. 2008. I used to run
I have switched to JUnit4.4 from JUnit3.8. I run my tests using ant, all

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.