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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:36:36+00:00 2026-05-25T21:36:36+00:00

I have some Junit unit tests that require a large amount of heap-space to

  • 0

I have some Junit unit tests that require a large amount of heap-space to run – i.e. 1G. (They test memory-intensive functionality for a webstart app that will only run with sufficient heap-space, and will be run internally on Win 7 64-bit machines – so redesigning the tests isn’t a practical suggestion.)

I am developing in Intellij IDEA, so I know I can set the JVM parameters (e.g. -Xmx1024M) for the test class. However, this is only for running the whole test class – if I want to run an individual test, I have to recreate the run congfigurations for that test method.

Also, those are IDE and box specific – so if I switch boxes (I develop on multiple machines) or one of my colleagues tries to run the tests, those settings are not transferred. (Also, other IDEs like Eclipse and NetBeans are used by my colleagues.) FWIW, we’re using mercurial for source code control.

For the build cycle, we’re using Maven, so I know how to specify the JVM parameters for that.

So:
– I’m looking for a way of specifying the JVM parameters that will apply for the whole test class and the individual test methods; and
– I’d like to share those specification across IDEs on any machine (having picked up the code from the repository).

  • 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-25T21:36:37+00:00Added an answer on May 25, 2026 at 9:36 pm

    In IntelliJ you can specify default settings for each run configuration. In Run/Debug configuration dialog (the one you use to configure heap per test) click on Defaults and JUnit. These settings will be automatically applied to each new JUnit test configuration. I guess similar setting exists for Eclipse.

    However there is no simple option to transfer such settings (at least in IntelliJ) across environments. You can commit IntelliJ project files to your repository: it might work, but I do not recommend it.

    You know how to set these for maven-surefire-plugin. Good. This is the most portable way (see Ptomli’s answer for an example).

    For the rest – you must remember that JUnit test cases are just a bunch of Java classes, not a standalone program. It is up to the runner (let it be a standalone JUnit runner, your IDE, maven-surefire-plugin to set those options. That being said there is no “portable” way to set them, so that memory settings are applied irrespective to the runner.

    To give you an example: you cannot define Xmx parameter when developing a servlet – it is up to the container to define that. You can’t say: “this servlet should always be run with Xmx=1G.

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

Sidebar

Related Questions

I want to run unit tests (Junit) on some model classes that typically will
I have a class that I made for some unit tests. Everything was going
I'm using Maven 3.0.3. I want to run some Junit tests in my test
I have two kinds of Unit tests (not integration test). Because of some strange
I have been debugging some existing code for which unit tests are failing on
I'm trying to write some unit tests for a gwt-dispatch service with JUnit. I'm
I have an ant task set up like so: <target name=unit-test description=unit tests depends=compile-tests>
I have some test classes that are making use of spring-batch, and hibernate. My
I use JUnit 4 in eclipse. I have some test classes in my package
I have a problematic situation with some quite advanced unit tests (using PowerMock for

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.