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 8484277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:20:14+00:00 2026-06-10T20:20:14+00:00

As part of a JUnit test (executed from ANT) I need access to a

  • 0

As part of a JUnit test (executed from ANT) I need access to a fair few properties that are not only environment dependent, but can also change from one run to the next. In order to not affect any of numerous other devs that might use the same build.xml I wanted to define these properties on the command line with the -D flag (they’re easily populated using a script). Reading about the <junit> task in ant I thought that these properties would be easily duplicated to the VM running the JUnit tests using the clonevm flag, but this doesn’t seem to work. A simple <echo> before the <junit> call confirms the properties are set correctly, and I then execute the JUnit tests with the following:

<junit
    printsummary="on" showoutput="true" timeout="${tests.timeout.value}"
    haltonfailure="false" errorproperty="test.error.occurred"
    haltonerror="false" failureproperty="test.failure.occurred" forkmode="perTest"
    maxmemory="${project.junit.maxmemory}" clonevm="true">
    <jvmarg line="${project.test.vmargs}"/>
    <sysproperty key="java.io.tmpdir" value="${java.io.tmpdir}"/>
    <formatter type="xml" usefile="true"/>
    <classpath>
        <path refid="build.test.classpath"/>
    </classpath>
    <batchtest fork="yes" todir="${test.rpt.dir}">
        <fileset dir="${test.bin.dir}">
            <include name="**/${test.classes.run}.class"/>
            <includesfile name="${test.run.includesfile}"/>
            <!-- ignore inner classes -->
            <exclude name="**/*$*.class"/>
        </fileset>
    </batchtest>
</junit>

I then attempt to read a property value using System.getProperty("property"); but always get null. I assume I must be doing something wrong so that the properties aren’t sent to the JUnit VM, or I’m not reading it correctly. Any ideas? I guess I could work around the problem (use the script to write a temporary properties file, then read that from the test), but I’d still like to know how to do this if it’s even possible.

  • 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-06-10T20:20:16+00:00Added an answer on June 10, 2026 at 8:20 pm

    Try using a nested syspropertyset element.

    See junit documentation

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

Sidebar

Related Questions

We have a JUnit test suite that we usually run from Eclipse. We have
There is part of ant script with junit task: ... <target name=test> <mkdir dir=path_to_report_dir>
I am writing a junit test in order to (surprisingly) test a part of
Part of my web application is a background script that polls from a beanstalkd
Part of the GUI I'm building using tkinter has a pop-up window that says
Part of my app caches web pages for offline viewing. To do that, I
Part of my table design is to include a IsDeleted BIT column that is
Part of a complex query that our app is running contains the lines: ...(inner
I have an extremely odd problem in my JUnit tests that I just can't
I'm working on a project to develop a custom Ant task. As part of

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.