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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:28:04+00:00 2026-05-29T06:28:04+00:00

This is really looks like some magic is going on and I’m interested to

  • 0

This is really looks like some magic is going on and I’m interested to understand why that happens 🙂

Here’s the unit-test I have:

public class SelectThemeActivityTest 
    extends ActivityInstrumentationTestCase2<SelectThemeActivity> {

    private final static int[] STATIC_ARRAY = { 0, 1, 2 };

    public SelectThemeActivityTest() {
        super("com.the7art.simplewallpaper", SelectThemeActivity.class);
    }

    @Override
    protected void setUp() throws Exception {
        super.setUp();
        // some array usage here - will throw NullPointerEcxeption on second test
        // see description below
        STATIC_ARRAY[0] = 2;
    }

    @Override
    protected void tearDown() throws Exception {
        super.tearDown();
    }

    public void testFirst() {

    }
    public void testSecond() {

    }
    public void testThird() {

    }
}

If I run this test case the first test completes successfully and all the rest fail by throwing NullPointerException from setUp() – the line which tries to access STATIC_ARRAY.

What puzzles me even more is the fact that if I change the test case to extend AndroidTestCase instead of ActivityInstrumentationTestCase2, then all tests complete successfully! Magic! 🙂

Also if I remove ‘static’ keyword from STATIC_ARRAY, tests succeed too.

So it’s clear that something is modifying my STATIC_ARRAY by making it null between a test runs, most probably in tearDown() and that something has to do with ActivityInstrumentationTestCase2, but how to track that something? 🙂 Any ideas?

  • 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-29T06:28:04+00:00Added an answer on May 29, 2026 at 6:28 am

    The reason is scrubClass() method called from super.tearDown(): google-groups discussion. A solution is – overriding this method.

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

Sidebar

Related Questions

Hi I have some file that looks like this: some row /folder1/folder2/folder3/folder4/folder5 *.kuku.* noku
This really seems like a bug to me, but perhaps some databinding gurus can
I have written a very simple file managing database that basicly looks like this:
I just saw this question and one of the answers looks really appealing to
I just cannot figure this out, it looks really simple but I'm relatively new
I've got this really simple piece of code that I thought was the correct
I've been having this really annoying thing happen the past few days, that has
The WSDL looks like this: <xsd:element name=Parent> <xsd:complexType> <xsd:sequence> <xsd:element maxOccurs=unbounded ref=tns:Child/> </xsd:sequence> </xsd:complexType>
I'm currently refactoring a class which currently looks something like this: class SomeModel {
I would really appreciate if you would take a look at this piece 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.