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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:24:55+00:00 2026-06-16T05:24:55+00:00

I am facing an issue with Maven and the Surefire plugin. I have two

  • 0

I am facing an issue with Maven and the Surefire plugin.

I have two tests: testDatePos.java and testDateNeg.java and for each test an environment variable must be set. It is the same environment variable (DATE_SHIFT) but not the same value (-1 and 1).

Is it possible to configure the section surefire-plugin in the pom.xml of maven to have those tests running?

Here is my pom.xml that exclude the testDatePos.java to have the mvn test running OK (I know this is NOT a solution):

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <configuration>
    <excludes>
      <exclude>**/testDatePos.java</exclude>
      <!-- this test needs the env variable DATE_SHIFT=1 but 
      the test testDateNeg.java needs it at -1 -->
    </excludes>
    <environmentVariables>
      <DATE_SHIFT>-1</DATE_SHIFT>
    </environmentVariables>
  </configuration>
</plugin>
  • 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-16T05:24:57+00:00Added an answer on June 16, 2026 at 5:24 am

    You can do this by specifying two different executions of surefire in your pom, and forking each execution.

    However, this means that these tests will only work when you’re running them from maven, or at least you have to change the configuration everywhere you run them from. So, for the tests which require a environment variable, I would add this to the @Before/@After (or @BeforeClass/@AfterClass) of those specific tests.

    @Before public void before() {
      System.setProperty("DATE_SHIFT", "-1");
    }
    

    This way, you don’t need to execute the tests in maven for them to work. You’ll probably want to store the original value of DATE_SHIFT and restore it at the end of the test.

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

Sidebar

Related Questions

I am facing issue with run simple Hbase example. I have create on HbaseTest.java
I'm facing the followinf issue : Failed to execute goal org.apache.maven.plugins:maven-ear-plugin:2.7:generate-application-xml (default-generate-application-xml) on project
I have been facing issue with sphinx result set for string attribute. Below is
We have implemented webservice which generates xml response. I am facing issue while invoking
I've facing an issue of push & pop my UIViewController. I've two UIViewControllers say
I'm facing an issue using eval function. Indeed I have some function name inside
I am facing an issue in getting the correct frame for two different strings.
I am facing an issue with this simple jQuery code. I have attached the
I'm new in android development and am facing issue with my test code .
I am new to Maven, I have to install maven plugin in eclipse. I

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.