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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:51:32+00:00 2026-06-18T11:51:32+00:00

I am creating a test suite for my android application and have this setUp

  • 0

I am creating a test suite for my android application and have this setUp method

    private static final String TAG_NAME = "TESTING_SUITE";
        public TestingMusicDAO musicDAO;
        public List<Song> songs;
        public Instrumentation instr;
        MusicService musicService;
    @Override
    public void setUp() throws Exception {
        instr = this.getInstrumentation();
        Log.d(TAG_NAME, "Setting up testing songs");
        musicDAO = new TestingMusicDAO(instr.getContext());
        musicService = new MusicServiceImpl(musicDAO);
        musicDAO.getAllSongsFromFile();
        songs = musicDAO.getAllSongs();
        for(Song song : songs)
            Log.d( TAG_NAME, song.toString() );
     }

And then have these tests which are created by a python tool from a text file

public void test1() {
    List<Song> testPlaylist;
    String testArtist = ("The Beatles");
    String actualArtist = ("TheBeatles"); 
    testPlaylist = testingPlaySongsByKeyword(testArtist);
    if(testPlaylist.isEmpty()){
        fail("No Songs Were Found");
    } else {
        for( Song loopsongs : testPlaylist){
            if (!(loopsongs.getArtist().equals(actualArtist))){
                fail("Song Doesnt Contain the artist" + actualArtist + "... Contains ->" + loopsongs.getArtist());
            }
        }
   }
}

and every time one of these gets called the musicDAO is regenerated. How can I stop the setup method from being called

  • 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-18T11:51:33+00:00Added an answer on June 18, 2026 at 11:51 am

    You don’t. The design of JUnit is that setUp() and tearDown() are done once per test. If you want it done per class, do it in the constructor. Just make sure that you don’t alter anything inside the classes. The reason for doing it once per test is to make sure all tests start with the same data.

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

Sidebar

Related Questions

I am creating Junit test cases in Spring. private static BeanFactory servicefactory = null;
I have a large acceptance test suite that runs the source application many thousands
I have the following couple of C pre-processor macros for creating test functions: //
This is just an early stage test of creating and writing a file to
Right now, if you have a test that looks like this: [TestMethod] [DeploymentItem(DataSource.csv)] [DataSource(
I'm creating an API using Tipfy . I have an existing suite that tests
I have an ASP.NET 4.0 application that implements URL routing. This gives me page
I have some expensive test setup that is only necessary for a handful of
I am using Selenium RC and I have a test case creating posts and
I'm working on creating a test suite that runs on multiple databases using dbunit

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.