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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:15:41+00:00 2026-06-18T12:15:41+00:00

We are following below practices to write JUnit tests for our methods. Each method

  • 0

We are following below practices to write JUnit tests for our methods.

  • Each method will be having their own class which holds all the tests which are required for that method. For e.g.: class test {…}

  • @Before will consists of per-requisites setup for methods like “Entity” so that when we do Edit we don’t need to copy/paste code for adding an entity at each method level.

Now here my question is, shall we delete all the data which we entered by writing code to trash test-data in @after method or just let it be?

I know we can make it configurable but what is best practice? keep it or delete it. As per my gut feeling deleting should be better as if there is some duplicate data already in db – it may trigger wrong true or false.

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

    As a best practice I would recommend to clear your data storage between every test, to guarantee each test is isolated from other tests.

    This could be done with the @After method if you want to keep some of the settings alive (from the @BeforeClassfor example). It could also be done in the @Before method for example by overriding variables with a new instance for every test, if you do so you do not need a clean up after the tests.

    To clean up your settings of the @BeforeClass method you should use @AfterClass for example to close a Database connection or something simular what only needed to be done once. But this is not needed for every kind of unit test.

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

Sidebar

Related Questions

[Edit] I've summarized the answer to the following below, the error lies in the
I have the following code below however am confused as to why the div
I have the following code below for list into master page <div id=header> <ul>
Given the following code below, how can I have it modified such that it
I have the following script below where I try to mimic a file upload
I have the following code below which works, but I want to insert values
I have the following listbox below which binds to a database table of image
I have the following function below: public function setupHead($title){ $displayHead .='<!DOCTYPE html PUBLIC -//W3C//DTD
i have the following code below: const char* timeformat = %Y-%m-%d %H:%M:%S; const int
With the following code below, There is an error saying File /home/user/web_pro/info/views.py, line 184,

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.