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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:13:32+00:00 2026-06-13T12:13:32+00:00

I’m currently experiencing a problem. I created 2 classes, one is abstract, the other

  • 0

I’m currently experiencing a problem. I created 2 classes, one is abstract, the other one is inherited from the first one:

public abstract class A {
        @BeforeClass
        protected void setUp() {
            Object o = new Object();
        }

        @AfterClass
        protected void tearDown() {
            o = null;
        }

        @Test
        public void T1() {
            // whatever is done here
        }

        @Test(dependsOnMethod={"T1"})
        public void T2() {
            // whatever is done here
        }
}

@Test(singleThreaded=true)
public class B extends A {

        @Test(dependsOnMethod={"T2"})
        public void T3() {
            System.out.println(o.toString());
        }
}

Actually, I got 2 different behaviours between Eclipse & Jenkins.

When I run my test under Eclipse, the execution order is:

setUp()
T1()
T2()
T3()
tearDown()

But under Jenkins, the execution order is:

setUp()
T1()
T2()
tearDown()
T3()

As a result, in the second case, T3() obviously fails, due to a NullPointerException as the Object o has been destroyed by the tearDown() method.
TestNG is called by Jenkins, by using the maven-surefire-plugin, by specifying a testng.xml file. Here it is:

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >

<suite name="TestSuite" parallel="classes" thread-count="1" verbose="1">
    <test name="Test B">
       <classes>
        <class name="main.pkg.B" />
       </classes>
   </test>
</suite>

Is there a way to make both Jenkins & Eclipse have the same behaviour ?
If so, any help would be very appreciated.

Regards,

Cedric

  • 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-13T12:13:33+00:00Added an answer on June 13, 2026 at 12:13 pm

    It may be that your testng plugin version in eclipse is different than the one in your project.

    When you run via jenkins using maven, it uses the testng dependency from your pom. Whereas in eclipse you may have configured some other testng plugin version which is used for the eclipse runs.

    I have 6.5.1 as testng dependency version in pom and 6.5.2 of the plugin version and I get the correct output from both. I earlier had testng 6.2.1 as my maven dependency and I could see the issue that you are seeing. So probably matching both versions may help.

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

Sidebar

Related Questions

I am currently running into a problem where an element is coming back from
I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I want use html5's new tag to play a wav file (currently only supported
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build

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.