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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:56:04+00:00 2026-06-13T22:56:04+00:00

What changes do i need to make to the following please? I’d like make

  • 0

What changes do i need to make to the following please?

I’d like make sure that testInsert method to only run when testInternalAccess passes and testInternalAccess not count as a failure.

@Test
public void testInternalAccess() {
    URL url = null;
    try {
        url = new URL("http://internalpage");
        InputStream is = url.openConnection().getInputStream();
    } catch (Exception e) {
        fail();
    }
}

@Test(groups = "database", dependsOnMethods = "testInternalAccess")
public void testInsert() {
  // some code
}

In the above example:

  1. testInternalAccess runs, fails and being reported as a failed test
  2. testInsert runs and fails

Or, using creator’s of TestNG example

@Test
public serverStartedOk() {}

@Test(dependsOnMethods = { "serverStartedOk" })
public method1() {}

How will method1 know whether server actually started ok? How will serverstartedOk communicate to the world it’s state?

  • 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-13T22:56:05+00:00Added an answer on June 13, 2026 at 10:56 pm

    Based on the discussion we had above, following is the brief summary.

    As you wish to run the method testinternalAcecess before you run all the tests in the class use @BeforeClass

    @BeforeSuite
    public void testInternalAccess() {
        URL url = null;
        try {
            url = new URL("http://internalpage");
            InputStream is = url.openConnection().getInputStream();
        } catch (Exception e) {
            fail();
        }
    }
    

    The method runs only once and before all tests run in the suite! And you test method would be some thing as below

    @Test(groups = "database")
    public void testInsert() {
      // some code
    }
    

    Bingo and this would work!

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

Sidebar

Related Questions

We need to make changes to an app that will cause all its URLS
I have an excel file that I need to make some changes. I need
Even .head doesn't work. What changes do I need to make to make this
I need to make some changes to an old Oracle stored procedure on an
I am C++ programmer and I need to make some changes to VB6 code.
I need to download file from FTP server and make some changes on it
I make DDL changes using SQL Developer's GUI. Problem is, I need to apply
I have 3 buttons to change language. So I need to make method, where
I am making some changes on an already established website and need to make
I need to make javascript code to swap images with option change. Here is

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.